Git Large File Storage
åè
Git Large File Storage (Git LFS) ã¨ã¯ã大容éãã¡ã¤ã«ãæ±ãããã®Gitæ¡å¼µããªã¼ãã£ãªã»ãããªã»ãã¼ã¿ã»ããã»ã°ã©ãã£ã¯ã¹ã¨ãã£ããã¡ã¤ã«ããªã¢ã¼ããµã¼ãã¼ã«æ ¼ç´ãããã¯ã¹ããã¤ã³ã¿ã¨ãã¦Gitã§ç®¡çãããã¨ãã§ããã
ç°å¢
OS X El Capitan Version 10.11.6 git version 2.10.0
ã¤ã³ã¹ãã¼ã«
$ brew install git-lfs $ git lfs install
使ã£ã¦ã¿ã
æ°è¦ããã¸ã§ã¯ãã®å ´å
ã¾ãã¯ãã¤ããªãã¡ã¤ã«ãç¨æããããã管çãããã¨ã«ãã:
$ touch README.md $ ls > large.bin
git-lfsã§ç®¡çãããã¡ã¤ã«ã®ãã¿ã¼ã³ãè¨å®ãã:
$ git lfs track '*.bin' Tracking *.bin
'*.bin'ã®ãã¿ã¼ã³ã«ããããããã¹ã¦ã®ãã¡ã¤ã«ã対象ã¨ãªãã
git-lfsã«ç®¡çããã¦ãããã¡ã¤ã«ãã¿ã¼ã³ã確èªããã«ã¯ãå¼æ°ç¡ãã§git lfs track
ãå®è¡ãã:
$ git lfs track Listing tracked paths *.bin (.gitattributes)
ã¾ããpre-push
ããã¯ã¨.gitattributes
ãä½æããã¦ãã:
$ cat .git/hooks/pre-push #!/bin/sh command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n"; exit 2; } git lfs pre-push "$@" $ cat .gitattributes *.bin filter=lfs diff=lfs merge=lfs -text
Herokuãªããã¯git-lfsã«å¯¾å¿ãã¦ããªãã®ã§ããã®pre-push
ããã¯ãåé¤ããªãã¨ãã¾ããã«ãã§ããªãã®ã§æ³¨æã
次ã«ãã®.gitattributes
ãã³ãããããå¿
è¦ããã:
$ git add .gitattributes $ git add large.bin $ git commit -m "Added bin"
git lfs ls-files
ã³ãã³ãã§git-lfs対象ã®ãã¡ã¤ã«ã確èªã§ãã:
$ git lfs ls-files 02c2d7a18e * large.bin
æ¢åã®ããã¸ã§ã¯ãã®å ´å
ãã§ã«ãã¤ããªãã¡ã¤ã«ãgit-lfsã使ããã«ã³ããããã¦ãããéä¸ããgit-lfsã§ç®¡çãããã¨ãã:
$ git init . $ ls > bar.bin $ ls > foo.bin $ git add . $ git commit -m "initial commit" $ ls > foo.bin $ git add foo.bin $ git commit -m "Second commit"
ãã©ãã¯å¯¾è±¡ã®ãã¡ã¤ã«ãå®ç¾©ãã:
$ git lfs track '*.bin' $ git add .gitattributes $ git commit -m "Now tracking bin files" $ git tag not_working
対象ã®ãã¡ã¤ã«ãå®ç¾©ãã.gitattributes
ãã³ãããããã ããªã®ã§ããã¤ããªãã¡ã¤ã«ãlsfãªãã¸ã§ã¯ãã«å¤æãããããã§ã¯ãªãã
ãã§ã«ã³ããããããã¡ã¤ã«ã®ãã£ãã·ã¥ãã¯ãªã¢ããããä¸åº¦ã³ããããç´ã:
$ git rm --cached *.bin $ git add *.bin $ git commit -m "Convert last commit to LFS"
git lfs ls-files
ã³ãã³ãã§å¯¾è±¡ã®ãã¡ã¤ã«ã確èªãã:
$ git lfs ls-files 4665a5ea42 * bar.bin 4665a5ea42 * foo.bin
ææ°ã®å±¥æ´ã®foo.bin
ãã¡ã¤ã«ã®ä¸èº«ã確èªããã¨ãlfsãªãã¸ã§ã¯ãã«å¤æããã¦ãããã¨ãããã:
$ git show HEAD:foo.bin version https://git-lfs.github.com/spec/v1 oid sha256:4665a5ea423c2713d436b5ee50593a9640e0018c1550b5a0002f74190d6caea8 size 36
éå»(ãã¤ããªãã¡ã¤ã«ãã³ããããç´ãå)ã®å±¥æ´ã®foo.bin
ãã¡ã¤ã«ã§ã¯ãã¾ã å¤æããã¦ããªã:
$ git show not_working:foo.bin bar.bin foo.bin
éå»ã®å±¥æ´ã®ãã¡ã¤ã«ãå¤æããã«ã¯ãgit-lfs-migrateã使ããããã