git : how to specify a default remote push-to branch?
Asked Answered
L

2

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'?

Linctus answered 30/8, 2010 at 10:5 Comment(1)
possible duplicate of Git: which is the default configured remote for branch?Wenonawenonah
C
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).

Clot answered 30/8, 2010 at 10:30 Comment(3)
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).Gaius
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.Linctus
@Shawn: that is normal: 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.Clot
M
-3

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

Malformation answered 30/6, 2013 at 0:38 Comment(1)
look at -u setting for git pushAreta

© 2022 - 2024 — McMap. All rights reserved.