Git LFSって使ったことなかったな。

pushしたら怒られた。そっか、デカいかw 100M以上のサイズはこうなるそうな。
$ git push origin main
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 407.57 MiB | 5.77 MiB/s, done.
Total 7 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: error: Trace: 6c5e53a6e8439f1e1ea80a30dc5f6316c4c0079fc596bb0a98e1e3fd230e519f
remote: error: See https://gh.io/lfs for more information.
remote: error: File external_resources/buildroot_dl_backup.tar.gz is 373.09 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To github.com:kinneko/My_LLM_buildroot-external-m5stack.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'github.com:kinneko/My_LLM_buildroot-external-m5stack.git'
たしかにデカいわw
$ ls -alh external_resources/
total 411M
drwxrwxr-x 2 kinneko kinneko 4.0K Feb 12 04:53 .
drwxrwxr-x 14 kinneko kinneko 4.0K Feb 12 04:52 ..
-rw-r--r-- 1 kinneko kinneko 374M Feb 11 13:57 buildroot_dl_backup.tar.gz
-rw-r--r-- 1 kinneko kinneko 11M Feb 11 03:58 buildroot-st2023.02.10.zip
-rw-r--r-- 1 kinneko kinneko 27M Feb 11 04:27 ubuntu-base-22.04.5-base-arm64.tar.gz
Ubuntuではパッケージ提供されているそうな。
$ sudo apt install git-lfs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
git-lfs
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 3,544 kB of archives.
After this operation, 10.5 MB of additional disk space will be used.
(snip)
macOSはこれ。
brew install git-lfs
Windowsはこれ。
git lfs install
デカいファイルをLFSに登録する。
$ git lfs track "external_resources/buildroot_dl_backup.tar.gz"
Tracking "external_resources/buildroot_dl_backup.tar.gz"
LFSに追加されたファイルの情報は.gitattributesに書き込まれるので、これもコミットする。
$ git add .gitattributes
$ git add external_resources/buildroot_dl_backup.tar.gz
$ git commit -m "Add large file to LFS"
[main a9b47d4] Add large file to LFS
2 files changed, 1 insertion(+)
create mode 100644 .gitattributes
rewrite external_resources/buildroot_dl_backup.tar.gz (99%)
なんかまだエラーが出るな。どうやら、forkしたプロジェクトでは、上流側で反映してもらえないと、新しいオブジェクト(ファイル)をアップロードできないため、プッシュが拒否されている模様。うーん。
$ git push origin main
batch response: @kinneko can not upload new objects to public fork kinneko/My_LLM_buildroot-external-m5stack
error: failed to push some refs to 'github.com:kinneko/My_LLM_buildroot-external-m5stack.git'
しょうがないので、新しいリポジトリを作って、そこに変更する。
BR2_M5LLM_buildrootでいいか。
https://github.com/kinneko/BR2_M5LLM_buildroot
$ git remote remove origin
$ git remote add origin https://github.com/kinneko/BR2_M5LLM_buildroot.git
$ git branch -M main
$ git push -u origin main
あ、これだとユーザー認証が面倒なやつだったわ。
こっちにしよう。
$ git remote remove origin
$ git remote add origin git@github.com:kinneko/BR2_M5LLM_buildroot.git
$ git branch -M main
$ git push -u origin main
To github.com:kinneko/BR2_M5LLM_buildroot.git1 MB/s
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'github.com:kinneko/BR2_M5LLM_buildroot.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
あー、先にpullしてないとダメ? あー、ライセンスとか指定しちゃったからか...
$ git pull --rebase origin main
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (3/3), 12.65 KiB | 80.00 KiB/s, done.
From github.com:kinneko/BR2_M5LLM_buildroot
* branch main -> FETCH_HEAD
* [new branch] main -> origin/main
Auto-merging LICENSE
CONFLICT (add/add): Merge conflict in LICENSE
error: could not apply 71e5dd7... [init]
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 71e5dd7... [init]
あー、コンフリクト。
$ rm LICENSE
$ git rm LICENSE
rm 'LICENSE'
$ git commit -m "WIP: Save local changes before rebase"
(snip)
だめ、壊れた。めんどくさい。やり直し。
mirrorつけてフルクローンする。
$ git clone --mirror git@github.com:kinneko/My_LLM_buildroot-external-m5stack.git
(sinp)
なんか、様子が違うなぁ...
$ cd My_LLM_buildroot-external-m5stack/
$ ls
branches config description HEAD hooks info objects packed-refs refs
M5LLM_BR2_buildrootプロジェクト作成。
$ git remote set-url origin git@github.com:kinneko/M5LLM_BR2_buildroot.git
error: No such remote 'origin'
mirrorするとorginないの?
$ git remote -v
ないなら追加。
$ git remote add origin git@github.com:kinneko/M5LLM_BR2_buildroot.git
$ git remote -v
origin git@github.com:kinneko/M5LLM_BR2_buildroot.git (fetch)
origin git@github.com:kinneko/M5LLM_BR2_buildroot.git (push)
$ git push --mirror
Enumerating objects: 1350, done.
Counting objects: 100% (1350/1350), done.
Delta compression using up to 4 threads
Compressing objects: 100% (855/855), done.
Writing objects: 100% (1350/1350), 211.96 MiB | 5.53 MiB/s, done.
Total 1350 (delta 335), reused 1350 (delta 335), pack-reused 0
remote: Resolving deltas: 100% (335/335), done.
To github.com:kinneko/M5LLM_BR2_buildroot.git
* [new branch] main -> main
なんか、引っ越しできた模様。
普通にcloneしてみる。
$ git clone git@github.com:kinneko/M5LLM_BR2_buildroot.git
Cloning into 'M5LLM_BR2_buildroot'...
remote: Enumerating objects: 1350, done.
remote: Total 1350 (delta 0), reused 0 (delta 0), pack-reused 1350 (from 1)
Receiving objects: 100% (1350/1350), 211.96 MiB | 8.47 MiB/s, done.
Resolving deltas: 100% (335/335), done.
$ cd M5LLM_BR2_buildroot/
$ ls
board configs LICENSE README.md
boot docs linux start_buildroot.sh
clean_buildroot.sh external.desc package toolchain
Config.in external.mk provides tools
これでいいかな。
デカいファイルを追加。
$ mkdir external_resources
$ cp -a ../../../My_LLM_buildroot-external-m5stack/external_resources/* external_resources/
$ ls external_resources/
buildroot_dl_backup.tar.gz ubuntu-base-22.04.5-base-arm64.tar.gz
buildroot-st2023.02.10.zip
LFS追加。
$ git lfs track "external_resources/buildroot_dl_backup.tar.gz"
Tracking "external_resources/buildroot_dl_backup.tar.gz"
$ git add .gitattributes
$ git add external_resources/buildroot_dl_backup.tar.gz
$ git commit -m "Add large file to LFS"
[main e470167] Add large file to LFS
2 files changed, 4 insertions(+)
create mode 100644 .gitattributes
create mode 100644 external_resources/buildroot_dl_backup.tar.gz
$ git push origin main
Uploading LFS objects: 100% (1/1), 391 MB | 11 MB/s, done.
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 4 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 580 bytes | 580.00 KiB/s, done.
Total 5 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:kinneko/M5LLM_BR2_buildroot.git
e9c2757..e470167 main -> main
いやぁ、ようやくできたっぽいよ。
いろいろめんどくさい...

100円投げ銭 https://kinneko.booth.pm/items/1963720
オリジナル投稿:
Git LFSやってみようと思っただけなのに...|kinneko|pixivFANBOX
https://kinneko.fanbox.cc/posts/9371332



