Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I revert back to earlier commit using source tree

I have a project stored on my Mac and created a repository for from that location to my project. I am able to commit using source tree but now I would like to revert back to an earlier commit so all my files in folder update? I'm not sure how i do this?

like image 357
burrGGG Avatar asked Jan 31 '15 16:01

burrGGG


People also ask

How do I revert back changes in SourceTree?

If you mean git revert then right-click on a commit in SourceTree and you'll find a command named "Reverse" in the contextual menu that opens.


2 Answers

Temporary Revert Back

If you want to temporarily go back to this commit, then come back to where you are.

Right click on the commit you want to revert to and click on "checkout".

Permanent Revert Back

This will add commits to revert all your work since this commit

Right click on the commit you want to revert to and click on "Reset <> to this commit".

enter image description here

like image 63
dminones Avatar answered Sep 23 '22 03:09

dminones


I think in above discussion @dominones and @Giraldi maybe misunderstand each other,

@Giraldi maybe want to delete those unwanted commits permanently in the GIT, and make the git go back to a certain history commit, from there he could start all over again, like you want to be fresh from the beginning of somewhere.

while @dmonones is showing just how to revert back to a status of your code in a history, discarding some code changes you did, which will mostly end up with a new commit aiming to remove a unwanted/mistaken change, without changing the git history.

To discard an already committed commit in git history, you need to use hard reset and push with force.

like image 23
SebastianX Avatar answered Sep 22 '22 03:09

SebastianX