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
1.

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
2.

git push origin HEAD

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

>Solution :

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.

Leave a Reply