Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-push

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?

like image 933
eoinoc Avatar asked Jun 24 '11 15:06

eoinoc


People also ask

What is git push vs git push origin?

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.

What is git push short for?

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.

Does git push push to origin?

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.


1 Answers

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.

like image 185
Amber Avatar answered Sep 21 '22 18:09

Amber