You can reset your branch to any previos commit by right-clicking the commit you want to reset to and choose Reset <branch> to this commit>
. You can choose to reset Soft
, Mixed
or Hard
.

DO NOT RESET HARD IF YOU WANT TO KEEP YOUR CHANGES! A hard reset is the easiest way to loose data in git. Instead, choosing Mixed
will reset the branch to the selected commit and keep the changes as unstaged changes; Soft
does the same, but the changes will be staged. You can then carefully select the changes you want to commit and create a new commit.
Disclaimer: You should not reset a repository if you already published your commits! If you already pushed your changes and anyone else bases his work on your commits, resetting or rebasing will lead to conflicts, since your new commits and your old commits will be around. In this case, you might want to remove the changes
you did not want to commit in a following commit, either by hand or by using git revert
.