Oliver Joseph Ash
Oliver Joseph Ash

Reputation: 2741

Git HEAD~1 behaving not as expected

Here is my git log:

I want to reset the most recent commit (top).

If I run git reset --hard HEAD~1, however, it takes me back by five commits!

Similarly, if I run git rebase -i HEAD~3, I expect to see the most recent three commits appear, but instead I get about 50!

What could be going wrong?

Upvotes: 1

Views: 109

Answers (1)

user1046334
user1046334

Reputation:

Your actual HEAD is merge, so it has multiple parents. If you write HEAD~1, git must choose from one of the parents. It just chooses the one you do not like.

Use the actual hash instead HEAD~1 in such situations.

Upvotes: 4

Related Questions