

The main thing is to understand the difference between revert and reset. Then, right click on a specific commit, and select 'Reset current branch to this commit'. Now for the GUI question you had, you can prob right click on the commit you want to get back to ( reset) or remove the changes that one commit made ( revert) by right clicking a commit in the history tree or maybe theres a button to do it. this is DANGEROUS operation so be careful if you use it, you can change the state for other users of the repo. you are changing the history of the project => when you perform git push you need to use the -force/ -f flag. reset: you will move the state of your repository history back in time and possibly lose all the changes that were made on top of that.you have not changed the history of the project but added to it => when you perform git push all is good Right-click on the previous commit, and youll see the option to revert this commit. this means you create a new node in the commit tree, i.e. revert: creates a new commit which is basically the opposite diff of the one created by the commit you are reverting (you'll see it in the automatic commit message).Regarding the part where you asked to get back to a older state there are 2 ways: That is the way git keeps track of your changes (and you can check it with the log command, or in the GUI tree view of the history, not sure how its called since i dont use GUI for git) git folder in the repository and assigns a hash to that change. Seems like it's a Sourcetree bug that 'log selected' is dim in step 2. Right-click on the deleted file and select 'Reset to commit' menu item.

Determine when the file was last committed. To answer your 1st question: after you run the commit command the file gets saved on your hard disk a s a normal file, but git also saves the diff of the change in the. Right-click on the deleted file and select 'Log Selected' menu item. Make sure you only use it to get rid of commits that haven't been pushed to another repository! This can cause some serious headaches if any of those lost commits have been pushed to a public repository. Ī note of warning that git reset will alter history - if I made several commits and then reset to the first commit, the subsequent commits will no longer be in the commit history. With the -hard option, it replaces the contents of your working directory with what was on. If you want to set your branch to the state of a particular commit (as implied by the OP), you can use git reset, or git reset -hard The first option only updates the INDEX, leaving files in your working directory unchanged as if you had made the edits but not yet committed them. It's more or less a way to 'undo' a commit and save that undo in your history as a new commit. Simply go to Log/History in source tree, select the previous commit of the commit which we you want to undo and right click and do Reset current branch to. The above answer is not quite correct - git revert does not set your repository to that commit - git revert creates a new commit that undoes the changes introduced by commit.
