Rails Dog Blog

Current Articles | RSS Feed RSS Feed

Untracked working tree file blah would be overwritten by merge


Just ran into a very annoying git error message that took a few minutes to figure out. I was merging changes from someone's Spree fork in Github into my master. I first pulled down their changes in a separate local branch. The change involved renaming two files due to a case issue in the filename.

The changes pulled down fine but git would complain when I tried to checkout my master branch again. What's weird about that was that git was saying that such and such a file "would be overwritten by merge." I wasn't trying to merge, just checkout the master branch (and then merge as a separate step.) 'git status' did not show any changes in the index (unsurprising) but I was basically stuck.

Here's how I fixed things. I did 'git checkout -f master'. Apparently the '-f' option was what I needed. Once I was back on the master I ran 'git status' and saw that the two files in question were deleted (as I had been warned about) and that these changes were considered untracked changes as far as git was concerned. The new files were not yet in the branch but that wasn't exactly a surprise. Next I did 'git merge branch-in-question' and that fixed everything to the way I wanted it. The files were renamed, the commit from the fork was in my log and there were no longer any unstaged changes.


Currently, there are no comments. Be the first to post one!
Post Comment
Website (optional)

Allowed tags: <a> link, <b> bold, <i> italics