I\'d like to improve my current aliases, most of them work over a branch. Is there a way to refer to the current branch in a git alias so I don\'t need to pass it each time?
It's not 100% clear from your question which of these two aliases you require.
This will push the currently checked out branch:
git config alias.po !f() { export tmp_branch=`git branch | grep '* ' | tr -d '* '` && git push origin $tmp_branch; unset $tmp_branch; }; f
This will push a given branch name (git po branchName
):
git config alias.po !f() { git push origin $1; }; f