When I do git revert via TortoiseGit, I get this lovely window :
However, when I want to do the same from the command line, the documentation manages to completely confuse me. How do I revert all local uncomitted changes?
The git revert command is used for undoing changes to a repository's commit history. Other 'undo' commands like, git checkout and git reset , move the HEAD and branch ref pointers to a specified commit. Git revert also takes a specified commit, however, git revert does not move ref pointers to this commit.
To revert a commit with GitKraken, simply right-click on any commit from the central graph and select Revert commit from the context menu.
If you want to revert the last commit, you can use git revert head . head refers to the most recent commit in your branch. The reason you use head~1 when using reset is that you are telling Git to "remove all changes in the commits after" ( reset --hard ) "the commit one before head" ( head~1 ).
To discard all local changes, you do not use revert. revert is for reverting commits. Instead, do:
$ git reset --hard
Of course, if you are like me, 7 microseconds after you enter that command you will remember something that you wish you hadn't just deleted, so you might instead prefer to use:
$ git stash save 'Some changes'
which discards the changes from the working directory, but makes them retrievable.
Assuming you haven't committed yet, you can also:
git checkout filename(s)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With