From 854df7bc220e343584a9c54a135decb3216f7f9b Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 6 Feb 2019 14:12:40 +0000 Subject: [PATCH] Add unamend alias to help reversing an amend * `unamend` applies the diff from a previous `commit --amend` to the working tree to make it easy to undo an accidental amend. * Removed `last` alias, use `checkout -` instead * Rename `name` alias to `refname` to be less ambiguous --- config | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/config b/config index 94ca06f..0368b8f 100644 --- a/config +++ b/config @@ -5,6 +5,11 @@ unstage = reset -q HEAD -- amend = commit --amend + unamend = !git diff $(git reflog -2 | \ + awk \"{print \\$1}\" | \ + sed -e ':a' -e 'N' -e '$!ba' -e 's/\\n/../g') | \ + git apply - 2> /dev/null || \ + echo \"error: last commit was not amended\" fixup = commit --fixup squash = commit --squash prepare = rebase -i --fork-point @@ -12,11 +17,10 @@ list = branch create = checkout -b delete = branch -D - name = rev-parse --abbrev-ref HEAD - last = !sh -c 'git reflog | grep \" checkout: moving from\" | head -n 1 | awk \"{ print \\$6 }\"' + refname = rev-parse --abbrev-ref HEAD - publish = !git push -u origin `git name` - unpublish = !git push -u origin :`git name` + publish = !git push -u origin `git refname` + unpublish = !git push -u origin :`git refname` force = push --force-with-lease changes = !sh -c 'git log --oneline $1..' --