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:
$