0

After fetching from remote (git fetch origin), I have the following commmit tree, and was working on "personal_commit"

---develop----origin/develop
       \----personal_commit.

I checked out back to develop, and try to perform a merge so that it fast-forwards to origin/develop. That way, I can later rebase my personal_commit on develop. But I get the error: "Your local changes to the following file would be overriden by merge" "Please, commit your changes or stash them before you can merge".

But there are no pending changes on the file itself ! Please help me to resolve this.

Notes:

  • Although this file is automatically generated, and I can discard it safely, it is possible that in one of the branches, I had removed it from the git repository in the past.

  • This answer does not work because there are no changes to stash or to commit.

git problem

Community
  • 1
  • 1
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101

1 Answers1

1

You have an untracked file AllDiagnostics.cs on your local machine, which is being fetched in the upstream code as well. Since git diff shows diff for tracked files only, hence it is not appearing in the output.

Also, you seem to have an ignore rule for the file in your .gitignore, because of which it doesn't appear in the output of git status either.

My suggestion would be to rename it to something else (mv AllDiagnostics.cs AllDiagnostics.cs.bkp), then do a git merge, and finally apply your changes from AllDiagnostics.cs.bkp to the freshly fetched file.

If this file was not supposed to be committed, you can untrack it later using

git rm AllDiagnostics.cs
git commit -m "removed AllDiagnostics.cs"
Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
  • Thank you, removing the file did the trick. I did not find however which one of the gitignore rules was making the file untracked. – Mikaël Mayer Sep 10 '14 at 14:04