I have my remote set up the following way:
git remote set-url origin --push --add <a remote>
git remote set-url origin --push --add <another remote>
based on this question: pull/push from multiple remote locations
Other people on my team only access the first repo. I have 2 machines. My first machines has access both remotes as described above. My second machine only has access to the second repo. My first machine's git remote show origin
shows (based on the configuration above):
Fetch URL: <the_first_remote>
Push URL: <the_first_remote>
Push URL: <the_second_remote>
As I understand it, you can't have two Fetch URLs with this approach. From my first machine, I normally do a git pull --rebase
and git push
to both remotes, and specify the branch when doing so (both in the the pull and push) This works fine except in the following scenario. In my second machine that can only access the second remote, I push a commit to that second remote. In the meantime, someone else pushes a changes only to the first remote. On my first machine (with both remotes set up as above) I pull in both changes and push them out to sync everything up. At this point I get this error message
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart.
So I end up having to do a git pull
(without --rebase
) or git pull --no-commit
to do a merge. The log ends up showing a merge commit. Is there any way to avoid this?