But if you really want separated "all" and "origin" remotes, you still can do correctly what you want.
The key is (one more time) in the pretty cool configuration of git.
Let's see what happens when you git push all
:
git pushes on the first url (okay)
git pushes on the second url (okay)
it then fetches the first url to update the remote branches of your repository, refs/remote/all
.
Why does git complains about having "commit in advance" ? Because it compares your current branch (master) with the upstream branch, which is origin/master.
The fact is, we can change (either one will suffice) :
the updated branch, so we fetch all into refs/remotes/origin rather than into refs/remote/all. In the [remote "all"]
config block, the line
fetch = +refs/heads/*:refs/remotes/all/*
means "update refs/remotes/all". So you've just to add/change it to :
`fetch = +refs/heads/*:refs/remotes/origin/*`
And it's done : git fetch origin
and git fetch all
will now have the same effect (update the origin/master
branch)
Warning : too much playing with fetch configuration can lead to a repository where you don't know what is really done. So keep it simple and logical.
- the remote branch that git compares your current one
If you git push --set-upstream all
, then your master branch will follow all/master rather than origin/master. So it won't complain about you having commit. Note that you have to to this only once, as the upstream branch is permanently retained.
In short :
Method 1 : Change fetch configuration for remote "all"
[remote "all"]
url = (url1)
url = (url2)
-fetch = +refs/heads/*:refs/remotes/all/*
+fetch = +refs/heads/*:refs/remotes/origin/*
Method 2 : make your branch follow all/master rather than origin/master
[branch "master"]
-remote = origin
+remote = all
merge = refs/heads/master