git error: The following untracked working tree files would be overwritten by checkout:

One of my 'get merge' operations failed due to a directory permissions problem, but once I fixed the problem and tried ro run the merge again I get the following error:

error: The following untracked working tree files would be overwritten by merge:

This gave me a little trouble to try and solve because git was trying to protect me from myself. Git had copied some of the files before the previous merge failed. This left me with some untracked files that would be "lost" if I continued with the 'git merge' or even tried to 'git checkout another-branch'.

The solution ended up being this:

$ git checkout -f another-branch

This forced git to go ahead and overwrite the files. I assume you could have used the '-f' option with merge also, but switching to the other branch and then back fixed the issue and I was able to merge without any trouble the next time. The following article helped me figure it out:

http://railsdog.com/blog/2008/08/11/untracked-working-tree-file-blah-wou...