Go back to a specific commit in Git

In my Bitbucket replica, I see the following:

repo

I would like to go back to where I was when I did this commit with an arrow pointing to it.

In my commit, where I deleted AutoMapper, I deleted a lot of files and folders, and I know that they want to get them back. I want everything to be the same as before when I committed 44f31d5 .

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

git revert HEAD~1 

And committing. I thought that I would return my last commit, instead I would return the second (if that makes sense).

+6
source share
1 answer

Here git revert HEAD~1 will return to your last commit, and if you want to return to a specific commit, use git revert commit_id , or in your case you can also use git revert HEAD~2 , which will flip you to the previous commit.

+3
source

Source: https://habr.com/ru/post/1013704/


All Articles