Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the result of `git push origin`?

Tags:

git

I worked on my local feature branch, foo. Then I wanted to push that new branch to origin so others could work on it. The normal way to do this is:

git push origin foo:foo

Which I eventually did, and it worked completely as expected, pushing up 61 objects. Before doing that, on a whim, I tried:

git push origin

Thinking maybe it would default to making a new remote branch based on the name of my local branch. The output was normal push output, with only 13 objects pushed up. The results were imperceivable. Nothing new showed up for the other devs or in my local repo after a fetch.

So what does git think I'm telling it to do when I do git push origin, and what effect, if any, did it have on my remote repo?

like image 602
John Bachir Avatar asked Jan 03 '11 17:01

John Bachir


1 Answers

It depends on your git version. In old version, it would try to push each and every local branche that is also present on the distant side. Since version 1.6.3, the behaviour is controlled by the push.default configuration option.

Values are:

  • matching : [the default] push all branch with same local and distant name
  • nothing : push nothing
  • tracking : will only push the current branch if it is tracking a distant branch
  • current : will push current branch
like image 63
Sylvain Defresne Avatar answered Oct 23 '22 07:10

Sylvain Defresne