Search code examples
gitgit-commitatlassian-sourcetree

How to rollback everything to previous commit


Recently in a project with multiple people, a commit was made as seen in the image below. Marked in red you can see a commit with the description/comment of 'Merge?'.

This commit added numerous files and altered numerous others and was never intended to take place.

Using what do I need to do to roll everything back to the commit highlighted in blue? (I am 8 commits behind as seen in the screenshot.)

sourcetree troubs


Solution

  • If you have pushed the commits upstream...

    Select the commit you would like to roll back to and reverse the changes by clicking Reverse File, Reverse Hunk or Reverse Selected Lines. Do this for all the commits after the commit you would like to roll back to also.

    reverse stuff reverse commit

    If you have not pushed the commits upstream...

    Right click on the commit and click on Reset current branch to this commit.

    reset branch to commit