Bureaucrats, confirmed, Administrators
4,558
edits
(Adds 'Undo last commit') |
No edit summary |
||
Line 81: | Line 81: | ||
Using <code>reset</code> you can even go backwards several commits if you want. | 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 | The entire internet tells you not to <code>reset</code> if you've already pushed. But if you're just pushing (from machine A: your desktop) to a remote (machine B: eg. GitHub) so that you can then pull those changes into another space (machine C: development/staging/production/other machine) you can push your changes with <code>--force</code>; and pull them from that other environment. It may be quicker and easier though to identify the SHA of the n-1 commit and then <code>reset</code> on machine C | ||
<source lang="bash"> | |||
git log -n 4 | |||
# find the commit SHA, and use it on machine C | |||
git reset --hard d89c004cfe4bd67838fb41c7a6644bb15feee5cc | |||
</source> | |||
Credit: there's a clear explanation at https://www.git-tower.com/learn/git/faq/undo-last-commit | |||
== Git Branch == | == Git Branch == |