Reputation: 4116
I merged the wrong way between two branches. I then ran the following:
git reset --hard HEAD^
I am now back at the previous commit (which is where I want to be). Was that the correct thing to do?
The bad commit is still in the repository, is that okay or should I do something else to remove it from the repository?
I have not pushed or committed anything else yet.
Upvotes: 13
Views: 5296
Reputation: 2176
Using the ^
with HEAD^
didn't work for me. Instead I had to use the reference from: http://gitref.org/basic/#commit
git reset --soft HEAD~
(git version 1.7.12.4 (Apple Git-37)
)
(Note: if you are using zsh
(as I do) you can also escape the ^
character instead of alternate command I gave above)
Upvotes: 1
Reputation: 7781
mmmm... git revert may be is what you need
Also this article could help you.
Upvotes: 0
Reputation: 14223
That's the right thing to do.
You can do a git gc
to garbage collect disconnected commits, but it's not necessary.
Upvotes: 15