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?
Simply, we can say that git push command updates the remote repository with local commits. And origin represents a remote name where the user wants to push the changes.
The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.
If you run the simple command git push , Git will by default choose two more parameters for you: the remote repository to push to and the branch to push. By default, Git chooses origin for the remote and your current branch as the branch to push.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With