Changes

Jump to navigation Jump to search
725 bytes added ,  11:39, 11 August 2018
Adds 'Undo last commit'
git log --stat
</source>
 
== Undo a commit ==
 
Sometimes a commit is just wrong or 'breaks the build' so to speak. If you really just want to '''undo''' a commit, then
<source lang="bash">
# view what changes were made in the last commit
git difftool HEAD~
# reset --soft will undo the last commit, but leave the changes locally as 'modified' files that you can re-work or commit.
git reset --soft HEAD~
# reset --hard will undo the last commit, and discard any changes that were made in the commit. Your work tree will be identical to the way it was after the prior commit.
git reset --hard HEAD~
</source>
 
Using <code>reset</code> you can even go backwards several commits if you want.
 
https://www.git-tower.com/learn/git/faq/undo-last-commit
== Git Branch ==
4,558

edits

Navigation menu