We're transitioning code to another host but need two remotes in the meantime (complications), but after some reading I'm not sure how to easily always fetch only from the original remote but always push to both remotes.
http://blog.plataformatec.com.br/2013/05/how-to-properly-mirror-a-git-repository/
I suppose I could try an alias command or script (Windows git bash here), but we use GUI tools as well and I'd rather not have a tangled mess of hoops to jump through each time, I just want all pulls to come from the original remote and all pushes to push to both remotes.
You can configure origin with 2 push urls like this:
git remote set-url --add --push origin <git://example-repo-1/example-1.git
git remote set-url --add --push origin <git://example-repo-2/example-2.git
Then on, you only have to do git pull
and git push
and git will take care of the rest.
Also, your origin's pull url will still be pointing at your functional repository so that should take care of itself.
You need to set 2 different repositories (remotes) with different names.
Then you can use each one desperately since they are 2 different repositories.
You can do it by adding each remote:
git remote add <name1> <url1>
git remote add <name2> <url2>
Now you simply handle it as 2 different origins .
#In order to fetch from all the configured remotes
git remote update
git pull <name1> <branchA> #pull from name1 repository
git push <name2> <branchA> #push to name1 repository
git pull <name1> <branchA> #pull from name1 repository
git push <name2> <branchA> #push to name1 repository
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.