git push origin HEAD

Posted: June 16, 2020

You don't have to type branch name when you push to origin like

git push origin feature/foo-bar

But just using HEAD is enough to push current branch,

git push origin HEAD

Every time I've typed the branch name when I push to GitHub for 6 years...

Now, I added pob alias to my .gitconfig and save my time for 5sec!

(also added alias for --force-with-lease to protect client side. I commonly use branch protection on GitHub side, but it's for only master branch. You can also use this to protect working branch from local client side)

# $HOME/.gitconfig

    # before I use this alias like `git po <branch name>`
    po = push origin

    # now I can just type `git pob` to push
    pob = push origin HEAD

    # branch protection for local client side 
    pf = push --force-with-lease