1

I try to pull from origin to update a local git repository, and got the familiar message:

error: Your local changes to the following files would be overwritten by merge:
    <list of files>
Please, commit your changes or stash them before you can merge.
Aborting

Okay, no big deal. I stashed my changes and pulled again... and got the exact same message. Okay, that's a bit weird.

So I tried adding and commiting the files... and it still won't pull, for the same reason.

Out of frustration, I deleted the offending file. And now I still get the same error, but the file doesn't even exist anymore.

I'm not entirely sure how to get it to stop tracking a file that doesn't exist... and I'm not sure why I can't pull from source.

git status shows:

# On branch master
# Your branch is behind 'origin/master' by 249 commits, and can be fast-forwarded.
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   <list of files>
#
no changes added to commit (use "git add" and/or "git commit -a")

Any suggestions?

nathan lachenmyer
  • 5,298
  • 8
  • 36
  • 57

1 Answers1

-1

Assuming you are in a state where you have no uncommitted changes you care about do

git reset --hard HEAD

And from the root of the repository then do

git clean -dfx 

Then try again, and if it doesn't work post a partial of the error and the output of git status

Andrew C
  • 13,845
  • 6
  • 50
  • 57
  • unfortunately that doesn't enable me to pull -- i still have a list of modified / uncommitted files, and i'm back to square one. – nathan lachenmyer Sep 19 '14 at 19:59
  • Are you sure that you did not forget "--hard"? That should remove all modifications. – folkol Sep 19 '14 at 20:33
  • I am having the same problem as the OP and this does not remove the file. 'git status' still lists it as "modified" – DQdlM Jan 13 '15 at 15:42
  • @KennyPeanuts line ending problem perhaps? – Andrew C Jan 13 '15 at 17:22
  • I don't know what it was doing. Best I could tell the file existed nowhere but git insisted it was modified even after the hard reset. I fixed it with this: http://stackoverflow.com/a/8888015/686481 – DQdlM Jan 13 '15 at 17:24
  • @KennyPeanuts that would have thrown out your local commits on master. Which certainly could fix this issue but can lose work too – Andrew C Jan 13 '15 at 17:56
  • Yeah, in this case I was lucky that I didn't have any pending commits. Whatever the issue was I couldn't seem to fix it without that nuclear option. – DQdlM Jan 13 '15 at 18:20