We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Let's have a look at some common Git LFS (large file storage) issues and how to fix them.
The issue that comes up most frequently is the following one:
Encountered x file(s) that should have been pointers, but weren't
When you try to switch to a different branch or reset the current branch, the operation will fail and you will get an error similar to:
$ git reset --hard HEAD
HEAD is now at 901b26383 Start work for preparing container project.
Encountered 2 file(s) that should have been pointers, but weren't:
testdata.zip
container.zip
The problem here is that the files indicated aren't checked in via LFS while the .gitattributes
file (where you keep track of which file patterns are tracked via Git LFS) indicates that all .zip
files are stored using Git LFS.
To fix the problem, the files need to be migrated to Git LFS. Migrate converts large Git objects to LFS pointers. The command to fix the errors is (which needs to be repeated for each file with this error):
$ git lfs migrate import --yes --no-rewrite "testdata.zip"
migrate: changes in your working copy will be overridden ...
migrate: checkout: ..., done.
$ git lfs migrate import --yes --no-rewrite "container.zip"
migrate: changes in your working copy will be overridden ...
migrate: checkout: ..., done.
After fixing the files, don't forget to push the changes back to the repository:
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 574 bytes | 143.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/pieterclaerhout/my-repo
0cdcb73ff..af31c0f64 develop -> develop
The above successfully converts pre-existing git objects to LFS objects. However, the regular objects still persist in the .git
directory. These will be cleaned up eventually by git
, but why not clean them up right away? To cleanup, you can run:
$ git reflog expire --expire-unreachable=now --all
$ git gc --prune=now
If you want to double-check which files are actually stored in Git LFS, you can use the git lfs ls-files
command to get a list of all files which are stored with LFS:
$ git lfs ls-files
dad4c5t3y1 * testdata.zip
d554b52b48 * container.zip
Another way of doing the same is using the git check-attr
command:
$ git check-attr --all -- container.zip | grep "filter: lfs"
container.zip: filter: lfs
If you want to learn more about Git LFS, you can consult the official website.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.