1

enter image description here

I would like to delete the commit 9dfd73, the one highlighted. As you can see it's not a branch. It's the result of a detached head.

I tried to make a branch on it and then delete that branch using git branch -D 9dfd73, but that deleted the branch, leaving the commit.

Any ideas?

UPDATE:

For some reason, that commit doesn't exit in my tree any more, and I didn't have the chance to try your solution.

But I'll mark it as the correct answer if you can explain what does that command really does :-)

git rebase --onto <9dfd73>^ <9dfd73> HEAD

I understand it's something like: "take all the commits between the commit 9dfd73 and HEAD (excluding HEAD itself) and put them on top of the commit 9dfd73"

But I don't understand the ^ symbol.

Also, I'm not sure if the ID should be the same. Could you explain further?

Thank you

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
RafaelGP
  • 1,749
  • 6
  • 20
  • 35

3 Answers3

1

Use the following command,

git rebase --onto <commit-id>^ <commit-id> HEAD

commit-id will be your SHA-1 id

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
1

You should try the file > reload menu in gitk (ctrl-F5). This will probably make your commit disappear, since it is not the current commit anymore and it is not on any branch.

François
  • 7,988
  • 2
  • 21
  • 17
  • This is the correct answer to my specific problem. I need to dig into git rebase --onto anyway, because that's a quicker way rather than creating a new branch and deleting it. Thanks – RafaelGP Apr 13 '12 at 14:23
0

If you insist on getting rid of it/them now, follow these instructions. But, dont' worry about it; it will eventually disappear on their own.

Community
  • 1
  • 1
GoZoner
  • 67,920
  • 20
  • 95
  • 145