While attempting to update my dotfiles locally on my MacBook Pro, I
ran into a bit of a dilemma with one of my files that I had edited but never

Not a big deal, I can just run git stash and apply the changes again later.
No such luck though, when attempting to stash I was advised that the file
needed merged:

% git stash
vim/.vimrc: needs merge

Kind of weird, but okay. Honestly, I don’t really remember what I did to get
into this state, but my next thought was to try to abort the merge, assuming
there was a merge in action:

% git merge --abort
fatal: There is no merge to abort (MERGE_HEAD missing).

So that was a bust. At this point, I made a copy of the locally modified file,
and then attempted to check it out, thinking that would get me back into a state
in which I could pull the latest code:

git checkout vim/.vimrc
error: path 'vim/.vimrc' is unmerged

Back to where we started, with a slightly different error message.

Running out of options, I tried to reset the file, to hopefully blow away any
gremlins in the state that were keeping me from moving forward:

% git reset vim/.vimrc
Unstaged changes after reset:
M	vim/.vimrc

So far so good. Evidently I had previously staged the file for commit but
never followed through with it. After doing a reset on the file, I was free to
stash or checkout the offending file, and get on with my day.

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

If you found this article helpful, please consider buying me a coffee.