In my case, I did simple one liner change to one of my file and wanted to commit my changes but noticed that commit -am "" did not add/commited the file.
After issuing git ls-files --stage
, I see probably all files in my project showing as duplicates. Here is example of one of the files
100644 6314bd3f89d1b794c6d8c0fb9bb4aa492e2d510a 0 SquirrelFoH/Squirrel.FoH.ViewModels/UserLoginViewModel.cs
100644 6314bd3f89d1b794c6d8c0fb9bb4aa492e2d510a 0 SquirrelFoH/Squirrel.FoH.ViewModels/UserLoginViewModel.cs
Interestingly, some of the files showing ad duplicates are not modified by me at all, some are but nevertheless, they show as duplicate and as you can see below, the casing is not the issue like in other SO posts on here.
UPDATE
While this does not resolve my issue described above, it helped me to use git reset --hard HEAD~1
which resets HEAD pointer to 2nd last commit which is the commit that worked. I use --hard
above to discard last commit since it caused the issue above for me.
If you need to keep these changes, using --soft
instead will reset HEAD to your commit before last commit and add changes in last commit to staging area.
git reset --hard HEAD~1
git reset --hard HEAD~2
git reset --hard HEAD~3
...
Above commands reset HEAD pointer 1, 2, 3, ... commits before last commit and discard any changes after. Use --soft
instead of --hard
if you dont want to discard these changes in which case these changes will be staged for you.
This is the situation I had. Below, last commit is commit A which is the one with the duplicates that started showing up after last pull of remote changes into my local branch. Commits B, C, ... are commits before commit A:
commit A
commit B - git reseat --hard HEAD~1
commit C
, now my last commit is commit B which does not have the duplicates. I can now try to merge again and see if I will have the same issue as I had with commit A. As I mentioned this does not solve the issue but at least allows me to try to recreate it or continue my work and deal with the merge later.
You will have to check if the issue persists in Git 2.22.1 (Q3 2019)/ Git 2.25 (Q1 2020), as The data collected by
fsmonitor
was not properly written back to the on-disk index file (on Mac, Linux or Windows)See commit b5a8169, commit d4c0a3a (24 May 2019) by Johannes Schindelin (
dscho
).(Merged by Junio C Hamano --
gitster
-- in commit 10432cc, 25 Jul 2019)With Git 2.25 (Q1 2020), fsmonitor is more robust, and removes an incorrect BUG() that should not trigger.
See commit 61eea52 (13 Nov 2019) by Junio C Hamano (
gitster
).(Merged by Junio C Hamano --
gitster
-- in commit aec3b2e, 01 Dec 2019)The index files can become corrupt under certain conditions when the split-index feature is in use, especially together with fsmonitor, which have been corrected with Git 2.41 (Q2 2023).
See commit 061dd72, commit be6b65b, commit 3b7a447, commit 3704fed (26 Mar 2023) by Johannes Schindelin (
dscho
).(Merged by Junio C Hamano --
gitster
-- in commit f315a8b, 04 Apr 2023)