Search code examples
gitgit-push

Does `git push` work as shorthand for `git push origin newfeature`?


I note that the default behaviour of git push origin is to "push all branches with same local and distant name".

If I create a new branch newfeature and check it out, will git push push the branch to origin by default?

Or do I need to use git push origin newfeature even when it's checked out?

Further, how does the command git push HEAD relate to this?


Solution

  • By default, it will push newfeature if and only if a branch called newfeature already exists on the remote.

    You can change this by using the push.default config variable.

    git push HEAD is essentially a shorthand for git push <name of checked out branch> if you have a branch checked out.