Search code examples
gitgit-lfsgit-lfs-migrate

Why does the number of commits increase after git lfs migrate?


I tried running git lfs migrate import --everything --include="*.dll" on a large repository. Before I ran this there were about 70k commits. After running the migration (and expiring reflog and pruning etc) git rev-list --all --count shows around 130k commits. Why are there so many commits added, and what are those commits?


Solution

  • I managed to figure it out with the help of the comments from @torek. As mentioned in a comment above, git rev-list --branches --tags listed the correct number of commits.

    The repository was created by using git tfs to convert a TFVC repository to git. Running git for-each-ref listed a bunch refs under refs/remotes/tfs, that did not show up when running git remote -v, due to the fact that these were listed as commits. So probably these referenced a bunch of the old commits that were not rewritten by git lfs migrate, and obviously the refs were not updated by git lfs migrate as sould probably be expected.

    Deleting all of these refs using git update-ref -d, and then doing another gc, seems to have fixed the problem and the repository was back to its original number of commits.