Search code examples
git

Git alias on current branch


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?

like this one:

git config alias.po "push origin"

is use it like that:

git po foo_branch

I'd like to just run git po and it to take the current branch as a parameter.


Solution

  • This answer will be valid starting from Git 2.0, where the default push behaviour will be simple

    Unless push.default setting is set to matching, git push without specifying argument will always push the current branch, so in this case you don't need to specify it.