How large files are kept
How large files work underneath.
In .gitattributes
Section titled “In .gitattributes”- A large file is stored the way Git LFS stores it, and
.gitattributessays which files are large, withfilter=lfs. The line Saturn writes isfilter=lfs diff=lfs merge=lfs -text, for*.endingwhen no other file in git has that ending, and for/the/fileitself when one has. - Git reads a file it already holds whole as changed from the moment a line starts to cover it, without the file being touched. A line that took in such files would make every one of them a change of whichever work saved next in a new folder, and that work would hold them all. That is why the line names one file where others share its ending. A file that ends up whole under a line anyway, because it was saved with plain git or shipped while the line was on its way, is moved over by the next save that sees it.
- The first time Saturn writes to
.gitattributes, it adds/.gitattributes merge=union, so that two people who each add a line get both lines, not a clash.
Settings and hooks
Section titled “Settings and hooks”- Once a project has large files, every git command is given the
filter.lfs.*settings thatgit lfs installwould write. They are not written anywhere, and they are only given where thegit-lfsprogram is found. - The
git-lfsprogram puts four hooks of its own in the project’s.gitfolder the first time it handles a file there. Three of them make every file markedlockableread-only after a commit, a merge or a switch, unless it is locked with Git LFS’s own locks, which Saturn does not use. So Saturn’s line for a large file does not saylockable, and every git command Saturn runs is givenlfs.setlockablereadonly=false. The fourth sends content before each push. Saturn runs git withGIT_LFS_SKIP_PUSH=1, which has that hook stand down, and sends the content itself. - Every git command is also run with
merge.lfs.driverset to a command that fails. Git would otherwise combine two versions of a pointer as text and leave marker lines in it. This way it stops with both versions whole, as it does for any binary file.
Fetching and sending
Section titled “Fetching and sending”- Git is told not to fetch a file’s content while it checks files out (
git-lfs filter-process --skip), so no merge can fail halfway through on a download. It writes the pointers. Afterwards Saturn fetches what the computer lacks, withgit lfs fetchfor the commit the folder is at, and copies each file’s content from.git/lfs/objectsover its pointer. The copy shares its bytes with the original on disks that can do that. - While
git lfs fetchruns, Saturn says how far it has got by looking at the disk four times a second: the content it is waiting for that is whole in.git/lfs/objects, and the parts of files still arriving in.git/lfs/incomplete, which Git LFS names by their ids. Saturn knows every id and size it asked for, so the figure is in bytes and needs nothing from Git LFS, which counts files and says little away from a terminal. An upload has no such place to look, sogit lfs pushis run withGIT_LFS_FORCE_PROGRESS=1and what it prints is read: files done, and bytes sent, rounded as it rounds them. - Before a branch is pushed, and before a ship is,
git lfs pushsends the content its commits name. If that fails, nothing is pushed.