Lets say we have origin
with a branch called master
which would be checked out by;
>> git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'
Now I add the remote fork
also with a branch called master
which would be checked out by;
>> git checkout -b fork-master fork/master
Switched to branch 'fork-master'
Your branch is up-to-date with 'fork/master'
This clearly knows what remote a given branch belongs to, and it even references the correct origin.
Lets say I want to push to origin I'd do this;
>> git push
Which would update origin/master with all changes (duh).
Below are 2 examples of pushes;
Example 1 **Correct!**;
>> git push fork fork-master:master
Example 2 **Fails**;
>> git push fork --all
This automatically pushes all fork
branches to origin
except for branch master
which will be rejected (in case changes where made).
What I thought example #2 would do is to push fork-master
to fork/master
, but this isn't happening.
Can I push all remote specific branches at once without having to point them to the correct remote branch name?
I'm asking because there are a lot of branches from time to time to push.
Configure default.push to upstream
Then, setup your local branches to track the respective remote branch:
Use the git branch command to verify each branch has its current upstream:
You can then use
git push <remote> <branch>
to push eachbranch
tobranch@{upstream}
automatically:I'm afraid there is no way to tell Git to push all branches which have their upstream set to a branch of a specific remote.
But better be specific anyway by passing all branches you want pushed on the command line. Lots of config options change behavior of push, so better be on the safe side.