Add git checkout-last alias

This commit is contained in:
Kenneth Benzie 2018-08-09 11:19:22 +01:00
parent 88e23013ec
commit dcacddc27f
2 changed files with 3 additions and 0 deletions

View File

@ -15,6 +15,8 @@ than remember the plumbing term of a specific command.
* `delete` deletes an existing branch, shorthand for `git branch -D`. * `delete` deletes an existing branch, shorthand for `git branch -D`.
* `name` the name of the current branch. * `name` the name of the current branch.
* `last` the name of the last branch checked out before the current branch. * `last` the name of the last branch checked out before the current branch.
* `checkout-last` checkout the last branch, shorthand for
`git checkout $(git last)`.
* `publish` push and set the tracking branch of a local branch to origin, * `publish` push and set the tracking branch of a local branch to origin,
shorthand for `git push -u origin <branch>`. shorthand for `git push -u origin <branch>`.
* `unpublish` delete a remote branch, shorthand for `git push origin :<branch>`. * `unpublish` delete a remote branch, shorthand for `git push origin :<branch>`.

1
config
View File

@ -11,6 +11,7 @@
delete = branch -D delete = branch -D
name = rev-parse --abbrev-ref HEAD name = rev-parse --abbrev-ref HEAD
last = !sh -c 'git reflog | grep \" checkout: moving from\" | head -n 1 | awk \"{ print \\$6 }\"' last = !sh -c 'git reflog | grep \" checkout: moving from\" | head -n 1 | awk \"{ print \\$6 }\"'
checkout-last = !git checkout `git last`
publish = !git push -u origin `git name` publish = !git push -u origin `git name`
unpublish = !git push -u origin :`git name` unpublish = !git push -u origin :`git name`