fREWdiculous!
22 May
This is almost entirely so that I remember how to do this. A big thanks for arcanez for showing me this in the first place.
In the Perl community, numerous important git repositories are hosted at shadowcat, but of course if you went to that url you would not be able to see all the work that I have spent on each of those projects. I like the fact that github has a nice concise view of my work.
The following is an example of a section from my .git/config in my DBIx-Class-DeploymentHandler:
1 2 3 4 5 6 7 8 9 | [remote "all"] url = dbsrgits@git.shadowcat.co.uk:DBIx-Class-DeploymentHandler.git url = git@github.com:frioux/DBIx-Class-DeploymentHandler.git [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = dbsrgits@git.shadowcat.co.uk:DBIx-Class-DeploymentHandler.git [remote "github"] fetch = +refs/heads/*:refs/remotes/github/* url = git@github.com:frioux/DBIx-Class-DeploymentHandler.git |
This lets you push to origin, github, or all. I tend to only pull from origin and push to all. Hopefully this can at least be a reference for people
4 Responses for "Syncing with Multiple Git Repos"
Thanks for this interesting tip; it helps me with maintaining repos that are both on github and on our in-house git server. I didn’t realize that you could have several URLs in one “remote” config section.
[...] Schmidt shares a quick trick on how to sync with multiple git repositories with a single git push [...]
This is a really handy trick. I had to come back to this blog a few weeks after reading about this trick after discovering a situation where I needed it.
As a side note, I found a couple of related tricks that were handy.
Say you have a shared commit repository on Github, but you want to maintain your own “fork” for your private branches that aren’t ready for anyone but you to use, you can do something like this
[remote "push-upstream"]
url = SomeOtherGitServer ; a private mirror perhaps
url = git@github.com:public-commonthing.git
url = git@github.com:my-fork.git
push = master
[remote "myfork"]
url = git@github.com:my-fork.git
fetch = +refs/heads/*:refs/remotes/myfork/*
push = master:master
push = mybranch1:mybranch1
push = mytopicbranch:mytopicbranch
And this /appears/ to Just Work.
Thanks, this will certainly come in handy!
Leave a reply