When running git reset --hard, the staged changes persist. Same goes for git checkout and git stash + git stash drop. What's going on?

StackOverflow https://stackoverflow.com/questions/17430400

  •  02-06-2022
  •  | 
  •  

Question

So here's some background: I'm trying to move a repository from Mercurial to git using hg-fast-export and when I do the last step (git checkout HEAD) there are still changes that persist in the repository. Specifically, it says that there are 4 deleted files that shouldn't be deleted.

When I try the following, nothing changes:

git reset --hard HEAD, git checkout ., git stash && git stash drop.

One thing I noticed is odd was that when someone was using this Mercurial repo, they added a git repo right in the middle of it T_T. So the interesting thing is when I run git checkout HEAD (but not when I run git checkout .), the .git subdirectory appears as deleted in the index (weird). These changes disappear whenever I run git reset but not without a bunch of errors flying past about an Invalid path.

Finally, that leaves the repository in the same state it was in when I first ran git checkout HEAD. (At least git's consistant!).

Surely a subset of the people converting mercurial to git has experienced this. Can anybody share their experiences with changes persisting within git?

Was it helpful?

Solution

The cause of this problem was indeed the fact that there was a .git directory inside the mercurial repository.

The way I solved it was running hg convert with a filemap excluding the trouble directory before doing the fast export conversion.

Hope this helps someone in the future!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top