15

Suppose I have a tracking branch named 'abc' which tracks origin/master.

When I'm on 'abc' and do a git push, it pushes 'abc' to 'abc'.
How do I specify the remote push branch for it with just a 'git push'?

kolypto
  • 23,092
  • 13
  • 75
  • 76
Shawn
  • 28,051
  • 17
  • 43
  • 68
  • 1
    possible duplicate of [Git: which is the default configured remote for branch?](http://stackoverflow.com/questions/4847101/git-which-is-the-default-configured-remote-for-branch) – Boris Guéry Aug 27 '12 at 08:42

2 Answers2

22
git branch --set-upstream-to abc origin/master

should be able to specify the remote branch.

Note the -to added to --set-upstream since git1.8.0.

Since Git1.7.0:

"git branch --set-upstream" can be used to update the (surprise!) upstream, i.e. where the branch is supposed to pull and merge from (or rebase onto).

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 1
    And if your git's older, it's pretty easy to just edit `.git/config` and put in the branch and remote you want (you should have your master branch as an example to copy from, if needed, since it's set up automatically when you clone). – Cascabel Aug 30 '10 at 12:45
  • I tried as you said. But when I do "git push", Git still doesn't understand that it's the current branch that I want to push up to the remote. It still pushs every tracking branch for me. – Shawn Sep 02 '10 at 01:53
  • @Shawn: that is normal: http://www.kernel.org/pub/software/scm/git/docs/git-push.html#OPTIONS. You need to do do `git push origin abc` otherwise you are using ':' which a special refspec used only for *matching* branch names. – VonC Sep 02 '10 at 02:17
-3

"git push" without a remote branch explicitly named will attempt to push to the site named "origin"

Sridhar Sarnobat
  • 19,595
  • 12
  • 74
  • 93