Bureaucrats, confirmed, Administrators
4,558
edits
No edit summary |
(Adds 'Undo last commit') |
||
Line 66: | Line 66: | ||
git log --stat | git log --stat | ||
</source> | </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 == | == Git Branch == |