Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Git URL for all local repositories

Recently, we migrated the Stash Git server to use HTTPS rather than HTTP. Now we have to update the URL in each of the repositories to use the new URL with HTTPS. Is there any way we can attain this without going to each of the repositories' Git config and changing the URL? The problem is we have almost 60 local repositories which we have to update.

Any solution to update the URL in one shot is much appreciated .

like image 464
EJo Avatar asked Jan 24 '26 14:01

EJo


1 Answers

Each developer can globally configure the url.<base>.insteadOf setting:

git config --global url."https://your-domain".insteadOf http://your-domain

This will cause URLs beginning with http://your-domain to be dynamically rewritten to start with https://your-domain:

Any URL that starts with this value will be rewritten to start, instead, with <base>. In cases where some site serves a large number of repositories, and serves them with multiple access methods, and some users need to use different access methods, this feature allows people to specify any of the equivalent URLs and have Git automatically rewrite the URL to the best alternative for the particular user, even for a never-before-seen repository on the site. When more than one insteadOf strings match a given URL, the longest match is used.

like image 143
Chris Avatar answered Jan 27 '26 02:01

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!