1

I'm having a bit of trouble reverting back to a certain git commit. I'm using Github and Sourcetree. How can I discard all changes after the commit "Typo" and revert to that state and work from there?

I've tried reset, but that doesn't seem to do the trick. If there is a terminal commando for git for this that is okay too.

My mess :-(

Matthijn
  • 3,126
  • 9
  • 46
  • 69

2 Answers2

2

You can revert all your files under your working directory and index by typing following this command.

git reset --hard <SHAsum of your commit>

For example if i have a commit that is called commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de Then i would write:

git reset --hard 4a155e5
Englund
  • 1,067
  • 7
  • 13
1

A simple git checkout -b newBranch <SHA of Typo commit> should do the trick. It would create a new branch pointing to your desired commit and checkout the content locally. This way you will not lose the commits after the Typo. If you need to remove them you will be able to remove the branch containing them, using: git branch -D <name of the branch> You can establish the SHAsum using git log.

dan
  • 13,132
  • 3
  • 38
  • 49