all repos — h3rald @ a4f29cdf59c7ee6da2580dc338fa18ec45f203c4

The sources of

Added spell.
Sun, 03 Mar 2024 11:00:12 +0100




1 files changed, 25 insertions(+), 0 deletions(-)

jump to
A contents/grimoire/

@@ -0,0 +1,25 @@

+----- +id: remove-last-git-commit +title: "Remove your last git commit" +subtitle: "Because some time you mess up but notice one second too late" +content-type: spell +----- + +Sometimes you get so much into the flow that you accidentally commit stuff too early, and typically notice right after committing. + +Undoing the last git commit is easy enough, thankfully. If you didn't push already, just run + +```bash +git reset HEAD^ +``` + +If you did push to your remote repository, but hopefully no one else pulled already, you can run the following command after the previous one: + +```bash +git push origin +HEAD +``` + +...which will _rewrite history_, but sometimes that's OK. + +Credits: StackOverflow [#1](, [#2]( +