Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull: error: Entry foo not uptodate. Cannot merge

Tags:

git

I'm trying to update my repo from a remote branch and keep getting this error when I do a "git pull". I haven't made any local changes, and even if I have I don't need to keep them.

I've tried:

git reset --hard

and I get the same problem

The only thing that seems to work is deleting the offending file and try a git pull again.

I've also tried git stash followed by a git pull. No go.

edit: using PortableGit-1.6.4-preview20090729 so any previous bugs with spurious errors should be fixed.

like image 493
yuit Avatar asked Aug 08 '09 05:08

yuit


2 Answers

This may happen if you update the index to ignore certain files:

git update-index --assume-unchanged <file>

and then for instance checkout some other branch:

git checkout <branch>
> error: Entry '<file>' not uptodate. Cannot merge.

Forcing index refresh fixes the issue:

git update-index --really-refresh
<file>: needs update

Followed by:

git reset --hard 

And then everything should be back to normal.

like image 51
habitats Avatar answered Sep 29 '22 01:09

habitats


There's a couple of ways to fix this but I've found git stash works good for me. It temporary puts your local changes into another place. Then you can pull, to grab the latest changes. And then you can get your local changes back.

Just like this:

$ git pull
...
...
file your_file.rb not up to date, cannot merge.

$ git stash
$ git pull
$ git stash pop
like image 38
manat Avatar answered Sep 29 '22 00:09

manat