I have a simple git alias:
shipit = push origin master
Is there any way to detect the current branch?
For example: push origin 'currentbranch'
HEAD to reference the current branch.
shipit = push origin HEAD
There might not be a current branch ("detached HEAD" mode, where
HEAD contains a raw SHA-1 instead of a branch name).
If there is a current branch, it is stored as a symbolic reference in
$ git symbolic-ref HEAD refs/heads/master $ git symbolic-ref --short HEAD master
HEAD is detached:
$ git symbolic-ref HEAD fatal: ref HEAD is not a symbolic ref
For the particular case of pushing, as Derek S already answered, you can just use the name
HEAD directly. (This works for some other commands too; for those where it's not available, use
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!Donate Us With