我正在迁移到GitLab.我需要编辑包含“github”的工作站上的所有.git / config文件,并用“gitlab”替换该单词.我怀疑使用单个find命令可以最轻松地完成此操作,而不是在每个文件夹中使用git调用.
我想它会是这样的:
find ./ -name ".git/config" -type f -exec sed -i 's/github/gitlab/gI' {} \;
这是一种安全/合理的方法吗?做这个的最好方式是什么?
编辑/更新:评论:我实际上不想为所有github repos做那个,因为它只是我控制的那些正在移动.我没有修改我的问题,但接受的答案包括仅针对一个github帐户的版本.我自己的答案下面最实际的是完成了改变每个文件的目标.
解决方法:
git config --global url."https://gitlab.com/".insteadOf "https://github.com/"
git config --global url."git@gitlab.com:".insteadOf "git@github.com:"
然后,使用github.com URL的任何git push / pull / clone都将使用gitlab.com.
So as not to change other GitHub packages I use, the following works for me:
06001
标签:git,linux,find,github,gitlab
来源: https://codeday.me/bug/20190611/1215965.html