Difference between git config push.default and git push origin HEAD


I have read about how we can configure our git push to push to the current branch we are in using

git config push.default current

but I also read about how you can push to your remote branch (to have the same name as your local branch) using

git push origin HEAD

When do you use 1 and when do you use 2?


If you set git config push.default current, then you can later just do git push. When you do git push origin HEAD, you are explicitly pushing to the HEAD commit to the origin remote.

p.s. You should use a branch name instead of HEAD.

Answered By – Code-Apprentice

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published