0

I've run into a problem wherein i cannot "back out" of a branch which I've started merging.

  • The branch is behind master
  • By checking out the branch, there are several files left from my last branch (master) that have been committed, but appear to be uncommitted in the context of the current branch

Thus, running:

$ git checkout master

Leaves me with the error: error: Untracked working tree file 'a' would be overwritten by merge.

I've tried running commands such as "git checkout -- ." and "git reset --hard" in hopes that git would "forget" that i tried to merge this branch with master, or by some other magic, loosen up .

However, I appear to be permanantly stuck on this branch.

Zoe
  • 27,060
  • 21
  • 118
  • 148
jayunit100
  • 17,388
  • 22
  • 92
  • 167

3 Answers3

1

Git is indicating that there is a file in the working directory that it is not tracking, but that is tracked by the branch you are trying to switch to. Git doesn't know if you created this file for some other purpose, and so it is not going to delete it for you.

The solution is to manually delete this file. You can also use git clean to remove all untracked files. (Be careful that you don't accidentally delete more files than you intended to!)

cdhowie
  • 158,093
  • 24
  • 286
  • 300
1

First cancel your merge:

git merge --abort

Then do a force-checkout of master:

git checkout -f master
Chronial
  • 66,706
  • 14
  • 93
  • 99
0

Try using git reset . to revert all changes in the current branch

Kevin Bowersox
  • 93,289
  • 19
  • 159
  • 189