Mikaël Mayer
Mikaël Mayer

Reputation: 10711

Git fetch and merge error but file not modified

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:

git problem

Upvotes: 0

Views: 132

Answers (1)

Anshul Goyal
Anshul Goyal

Reputation: 76997

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"

Upvotes: 1

Related Questions