I'm migrating to GitLab. I need to edit all the .git/config files on my workstations which contain "github" and replace that word with "gitlab". I suspect that this can be done most easily with a single find
command, rather than using a git
call in each folder.
I think it would be something like:
find ./ -name ".git/config" -type f -exec sed -i 's/github/gitlab/gI' {} \;
Is this a safe/reasonable approach? What is the best way to do this?
Edit/Update: Comment: I actually do not want to do that for all github repos, since it is only the ones I control which are moving. I haven't revised my question, but the accepted answer includes a version to target only one github account. And my own answer below most literally accomplishes the goal of changing every file.
You don't have to, you can use a single rule with an insteadOf
directive.
git config --global url."https://gitlab.com/".insteadOf "https://github.com/"
git config --global url."[email protected]:".insteadOf "[email protected]:"
Then, any git push/pull/clone
using a github.com
URL would use gitlab.com
instead.
The OP CPBL mentions in the comments:
So as not to change other GitHub packages I use, the following works for me:
git config --global url."[email protected]:cpbl".insteadOf "[email protected]:cpbl" git config --global url."[email protected]/cpbl".insteadOf "[email protected]/cpbl"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With