Reputation: 1291
I have a git repo that makes use of a few different remote urls. Is there a way I can set things so that these remotes are included in a clone of the repo. As it stands, every time I clone the repo, the clone includes only the standard remote reference pointing to origin.
If I can't get the master (i.e. upstream) repo to store and distribute these remote links, is there any handy way that I can get them to set after cloning that is commonly used. I'd think we could write a hook for this, but there doesn't appear to be a 'clone hook'.
Upvotes: 2
Views: 276
Reputation: 84453
There is (unfortunately) no post-clone hook, but you can certainly append more than one URL to each remote. For example, on a freshly-clone repository, the following will add two additional URLs to origin:
awk '/url =/ {
print;
print "\turl = http://1st.example.com/foo.git";
print "\turl = http://2nd.example.com/bar.git";
next;
};
{ print }' .git/config | tee .git/config
This will enable you to push all three URLs in sequence when you git push origin
. You can adjust the pattern and print statements to suit if your needs are more complex.
Upvotes: 2