19

On my Bitbucket Repo, I see this:

repo

I would like to get back to where I was when I made that commit with an arrow pointing to it.

In my commit where I removed AutoMapper, I removed many files and folders and I know want them all back. I want all to be same as before when I made the 44f31d5 commit.

I thought this would be common, so I tried all sorts from posts I found on SO (you can see my attempt) and this didn't work! I got that last commit by doing

git revert HEAD~1

And committing. I was thinking that would revert my last commit, instead I revert the second (if that makes sense).

1
  • 4
    The accepted answer is not the right one. git revert HEAD~1 will revert the "second commit" like you mentioned in your question. The right way is git revert HEAD. Commented Aug 13, 2018 at 15:32

1 Answer 1

5

Here, git revert HEAD~1 will revert to your last commit, while if you want to revert to a specific commit, then use git revert commit_id or in your case you can also use git revert HEAD~2 which will roll you back to previous two commits.

Sign up to request clarification or add additional context in comments.

3 Comments

Note that git revert commit_id does NOT revert to that commit, but instead reverts what that specific commit did.
No, git reset changes the pointer, revert creates new commit.
How many more people will fall for this misleading answer?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.