What is the process to revert back to a previous commit if you are using sourcetree? Please no command line help, I understand how you would achieve the same result there but am specifically looking to do it with my friendly atlassian tool.
Asked
Active
Viewed 2.7k times
9
-
You use the incredibly obscurely named --git revert command... – AMAN77 Apr 01 '16 at 11:44
-
1I'm asking because "revert" is a generic term and different people mean different things when they say "revert". Sometimes it is used instead of "reset", other times instead of "undo" and so on. If you mean [`git revert`](https://git-scm.com/docs/git-revert) then right-click on a commit in SourceTree and you'll find a command named "Reverse" in the contextual menu that opens. Now I realize Atlassian didn't use the word "revert" for it. It's unusual; commands they put in the program have the same name as the `git` commands the program runs in the background. – axiac Apr 01 '16 at 12:20
1 Answers
15
What exactly do you mean by revert?
You can commit a reverse commit by rightclicking on a commit and selecting Reverse commit
. This will effectively create a new commit that negates the changes you made in your selected commit.
The commit with the changes you negated will still exist.
You can checkout an earlier commit by doubleclicking on an earlier commit or rightclicking and selecting checkout
. This will change your code to the state it was for your selected commit, so without the changes from later commits.
The commit with the changes you negated will still exist.
You can reset to an earlier commit. This will remove the commit with the changes you want to negate. (They can normally still be recovered using the reflog)

miva2
- 2,111
- 25
- 34
-
1Right clicking on a commit and selecting Reverse commit seems to do the trick. Thank-you – AMAN77 Apr 01 '16 at 12:14
-
http://flummox-engineering.blogspot.com/2014/10/how-to-undo-git-commit-in-sourcetree.html This confirms what you laid out as well. – AMAN77 Apr 01 '16 at 12:18
-
Nice screenshots, good find! Yeah there are multiple ways to "undo" depending on what exactly you want. – miva2 Apr 01 '16 at 12:20
-
1I would understand: bring it to a pushed version and remove all my local (commited and uncommited), unpushed, versions. – Dirk Schumacher Sep 10 '18 at 07:42
-
1Great answer. For any reader that **checkout** (after follow the answer) already, doesn't do any meaningful edit, and want to change your code back (e.g. because you finish reviewing) to the most recent commit (e.g. undo the checkout), just do another **checkout** by click the newest commit. Hope that my comment is not confusing. – cppBeginner Jun 30 '22 at 03:57