tags:

views:

39

answers:

1

I've checked in some changes to my local repository that I want to push, but when I do a git pull, I get:

Paul-Butchers-MacBook-Pro:TouchType-Build paul$ git pull error: Untracked working tree file 'documentation/Android/SwiftKey/buttons.xcf' would be overwritten by merge. Aborting

My working tree contains no untracked files:

Paul-Butchers-MacBook-Pro:TouchType-Build paul$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 26 different commit(s) each, respectively.
#
nothing to commit (working directory clean)

The commits that I've made do not touch the file that it's complaining about.

I've read answers suggesting that I do a git reset HEAD --hard, but I'm not sure what effect that will have on the commits that I've made?

Thanks in advance for any help

+2  A: 

It's not the commits you've made that touch the file, but the commits that you're pulling. Inspect the remote branch you're tracking to see what's happened. For example, git log master..origin/master will show all the commits that have happened on origin/master since you last pulled. According to your output above, there are 26 of these. Using the --name-status option will show which commit added the file.

You will need to rename the offending file, do the pull, and then move it back (overwriting the copy from the repo). git diff filename will then tell you how your copy differs from the one that someone else has committed to master. You can then commit the differences, or throw them away with git checkout filename.

You will need to use git pull --rebase to rebase your recent commits on top of the ones in origin. Once git status says master is ahead rather than diverged from origin/master, you can push.

Neil Mayhew
Thanks Neil - just before I received your answer, I managed to work out that the problem was that the "Swiftkey" directory had been renamed "SwiftKey" by another user. Because OSX's file system isn't case sensitive, that's what was causing my problem :-(
Paul Butcher
For the record, I overcame the problem by removing that portion of my local tree (safe, because none of my changes touched it), then doing git pull followed by checkout -- on the tree I previously deleted.Eugh.
Paul Butcher
Case insensitivity can be the source of a lot of problems. I've had the same thing with svn and it can be hard to spot what's going on.I tried using a case-sensitive root volume on my Mac at one time, but lots of applications broke. Adobe CS, in particular, refuses to install to a case-sensitive volume, and the company refuses to fix their applications.
Neil Mayhew