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
This commit is contained in:
Kenneth Benzie 2019-02-06 14:12:40 +00:00
parent e63768ba22
commit 854df7bc22

12
config
View File

@ -5,6 +5,11 @@
unstage = reset -q HEAD -- unstage = reset -q HEAD --
amend = commit --amend 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 fixup = commit --fixup
squash = commit --squash squash = commit --squash
prepare = rebase -i --fork-point prepare = rebase -i --fork-point
@ -12,11 +17,10 @@
list = branch list = branch
create = checkout -b create = checkout -b
delete = branch -D delete = branch -D
name = rev-parse --abbrev-ref HEAD refname = rev-parse --abbrev-ref HEAD
last = !sh -c 'git reflog | grep \" checkout: moving from\" | head -n 1 | awk \"{ print \\$6 }\"'
publish = !git push -u origin `git name` publish = !git push -u origin `git refname`
unpublish = !git push -u origin :`git name` unpublish = !git push -u origin :`git refname`
force = push --force-with-lease force = push --force-with-lease
changes = !sh -c 'git log --oneline $1..' -- changes = !sh -c 'git log --oneline $1..' --