Question

I created a tracking branch so whowasout.com tracked whowasout.com/master

$ git remote -v
origin  git@github.com:venkatd/whowentout.git (fetch)
origin  git@github.com:venkatd/whowentout.git (push)
whowasout.com   git@git01.phpfog.com:whowasout.com (fetch)
whowasout.com   git@git01.phpfog.com:whowasout.com (push)


$ git branch -vv
  master        c33b5dc [origin/master] Merge branch 'whowasout.com'
* whowasout.com 7b6b240 [whowasout.com/master: ahead 1] print statement in test.
php

When I commit some changes in the whowasout.com branch and execute "git push", master gets pushed to origin/master. Is this expected behavior? I was expecting whowasout.com to push to whowasout.com/master.

To push my changes, I currently type "git push whowasout.com whowasout.com:master" but I thought tracking would make this process quicker. Am I on the right track?

Was it helpful?

Solution

You will have to do:

git push whowasout.com whowasout.com:master

This is because whowasout.com doesn't have a branch whowasout.com and you don't want one. What you really want is to push whowasout.com branch on local to master on whowasout.com remote, which has to be done like above.

To get the behaviour that you want so that just git push pushes from whowasout.com branch on local to master on remote, you have to set the push.default config to upstream ( previously called tracking)

git config push.default upstream

Note that you have to do this because, by default, tracking branches are helpful in tracking the upstream branch when you are doing fetch / pull. When you change the push.default setting, it comes into play in push as well. Otherwise, push just pushes matching refs, i.e whowasout.com branch will be pushed to whowasout.com branch on remote whowasout.com.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top