This is a follow up to the Git LFS Basics post – some additional notes on LFS.
Partial Clone
If the storage space is not a concern (e.g., Bitbucket's 2 GB hard limit), then partial clone and sparse checkout may replace the need for LFS. They are still in early stages, though.
Case Sensitivity
Windows file system is case insensitive, but git is case sensitive, so there may be problems when specifying the tracking pattern. According to this open issue (which was based on an older issue), you can use regex patterns, e.g., git lfs migrate import --include="*.[dD][lL][lL], *.[eE][xX][eE], [Bb]in/"
. Specifying it as "*.dll, *.DLL"
doesn't work as expected.
LFS File Size Report
LFS has a built-in feature that will go through the history and report on the file types and sizes.
$ git lfs migrate info migrate: Fetching remote refs: ..., done. migrate: Sorting commits: ..., done. migrate: Examining commits: 100% (1681/1681), done. *.dll 5.6 GB 2013/2013 files(s) 100% *.exe 3.6 GB 546/546 files(s) 100% *.dat 1.9 GB 2/2 files(s) 100% *.zip 1.7 GB 16/16 files(s) 100% *.war 595 MB 17/17 files(s) 100%
The thing is, it defaults to showing only the top five. To show more, use the --top
option, e.g., git lfs migrate info --top=100
Create .gitattributes Before or After Migrate?
Per migrate import documentation, it will create .gitattributes
for you (except on certain cases based on options passed in). One thing it doesn't tell you is where it's added - it adds it to the very first commit in the history – it rewrites the very first commit (which is not surprising since rewriting history is one of the main tasks for LFS).
Find Lingering Large Files After the Migration
After migrating to LFS, if you find that the repo is still too large, you may want to run git lfs migrate info
again, but it won't show any files. Instead, you can use git ls-tree
to find large files in the repository. For example: git ls-tree -r -l --abbrev --full-name HEAD | sort -n -r -k 4 | head -n 10
Viewing Differences
There's no git lfs diff
, and git log
will show differences in "pointer" files, not the content. But in some cases, it might be useful to be able to view the differences. One way to do it is by using the external diff tool, e.g., git difftool HEAD^ HEAD Document.pdf
(assuming you have difftool already configured). Note that in Bitbucket, if you browse to the source file tracked as LFS, it won't let you view the differences in the UI even if it's a "text" file, it just allows you to download the file.
No comments:
Post a Comment