1

I've some trouble with git. I made some mistakes with merging pull requests, and now I need to come back to specyfic version of code from chosen commit. img -> problem

So. I need to back to the version of code from commit selected on img by red arrow. How can I do this in safe way?

What I want to get from solution? I need to remove commits and everything which was made in this commits.

2 Answers2

0

git checkout <sha_of_desired_location>

Then, if you do not want your recent commits, you can delete the branch.

git branch -d <branch you want to delete>

Then, the last step is to create a branch pointing to your current location

git checkout -b <branch_name>

Ben W
  • 930
  • 6
  • 16
0

If you don't want to reset (because that would means a git push --force, rewriting the history of the branch), you can revert multiple commits as in here

git revert @~x..@

That will create a new commit which cancels intermediate commits, and that you can push.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250