I have read every single post on here about similar issues but none of them are same as mine.
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.