tags:

views:

84

answers:

2

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.

+8  A: 

That's the right thing to do.

You can do a git gc to garbage collect disconnected commits, but it's not necessary.

James Gregory
Well, it'll take 90 days before `git gc` removes that commit. Commits reachable from the reflog count as reachable, and the reflog takes 90 days to expire (by default). But the gist of the answer is right: git's looking out for you, trying not to permanently delete anything, just in case.
Jefromi
Thanks James and Jefromi.
Justin
@Jefromi: Nailed it. I try not to suggest `gc` to people, because it's about the only non-reversible operation in git.
James Gregory
You could also do git reset --soft HEAD^
Mike Weller
A: 

mmmm... git revert may be is what you need

Also this article could help you.

microspino
Thanks, however I did not want to generate a reverse commit.
Justin