There are a couple ways to handle this. If your goal is to push the current branch, you can just write HEAD
: git push origin HEAD
.
If you want to push the default branch, that's a little trickier, since Git doesn't intrinsically have the idea of a default branch. If you want to use the remote's current branch, which on GitHub is the default branch, you can write this:
$ git push origin $(git rev-parse --abbrev-ref origin/HEAD | cut -d/ -f2)
Note that you may need to run git remote set-head -a origin
once to set origin/HEAD
, and you'll need to run it if the remote branch name changes, but this is the easiest way to automatically pick the right branch (which, admittedly, isn't that easy).