This can happen when you do a checkout that contains files which should have been been tracked by LFS as specified in .gitattributes
but somehow they've been committed directly instead. Most likely you have another program managing your repository such as a git GUI or IDE.
This can be frustrating because these files appear out of nowhere and prevent you from making checkouts. As soon as you stash your changes they return! If you get stuck in this situation, a quick fix is to commit these changes on a temporary branch so that you can checkout again.
To genuinely fix this problem, make sure you've committed the files as LFS pointers. This should be as simple as using git add
. Check your work using git lfs status
before committing. git lfs ls-files
will show what files LFS is managing.
git lfs status
is misleading since it reads Git LFS objects to be committed
when it really lists all changes. Files that you expect to be tracked by LFS should read something like (LFS: c9e4f4a)
or (Git: c9e4f4a -> LFS: c9e4f4a)
and not (Git: c9e4f4a)
.
By way of example, I found this to be a problem when adding image assets through Xcode 9.2 where I added "CalendarChecked.png" which it automatically added:
$ git status
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: Example/Assets.xcassets/CalendarChecked.imageset/CalendarChecked.png
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Example/Assets.xcassets/CalendarChecked.imageset/CalendarChecked.png
$ git lfs status
Git LFS objects to be committed:
Example/Assets.xcassets/CalendarChecked.imageset/CalendarChecked.png (Git: c9e4f4a)
Git LFS objects not staged for commit:
Example/Assets.xcassets/CalendarChecked.imageset/CalendarChecked.png (File: c9e4f4a)
$ git add Example/Assets.xcassets/CalendarChecked.imageset/CalendarChecked.png`
$ git lfs status
Git LFS objects to be committed:
Empty/Empty/Assets.xcassets/CalendarChecked.imageset/CalendarChecked.png (LFS: c9e4f4a)
Git LFS objects not staged for commit:
$
git-lfs
. I don't actually use git-lfs so I'm not sure about this (nor what to do about it), but if so, maybe the git-lfs tag would be good. – Cubitierefilter=lfs diff=lfs merge=lfs
entries to your.gitattributes
that match already commited files. If you want to make sure, they are converted at the same time, usegit rm --cached .
andgit add -A
to switch them to LFS pointers. (Of course assuming you are on an otherwise clean working directory.) If you forget to convert them, the problem may show up much later. I am not sure when exactly - probably when they get touched somehow. – Tacticiangit lfs pull
in the repo before committing resolved this issue for me – Imperiumgit lfs pull
, but it didn't help @Tilman Vogel, your comment seems to be directed to the person who enabled LFS for the repo, which isn't me. Is there anything I can do? Should I try to find out who enabled LFS and get them to help? – Ci