Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 992
Shawn Avatar asked Aug 30 '10 10:08

Shawn


People also ask

How do I force a remote branch to push?

You can also do git push -f as long as the remote branch you want to push to is the most recent one you pushed to. "will force push all local branches" - Why would it push anything but the active branch?

Does git push automatically push to current branch?

By default, Git chooses origin for the remote and your current branch as the branch to push. If your current branch is main , the command git push will supply the two default parameters—effectively running git push origin main .


1 Answers

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).

like image 113
VonC Avatar answered Oct 19 '22 10:10

VonC