仓库地址自动替换:
git config --global url."ssh://username@gerrit.example.org:29418/".insteadof "ssh://gerrit.example.org/" --replace-all
git config --global url."ssh://username@gerrit.example.org:29418/".insteadof "ssh://gerrit.example.org:29418/" --add
git config --global url."ssh://username@gerrit.example.org:29418/".insteadof "http://gerrit.example.org:8080/" --add
git config --global url."ssh://username@gerrit.example.org:29418/".insteadof "http://UserName@gerrit.example.org:8080/" --add
- 访问
ssh://gerrit.example.org/
/ssh://gerrit.example.org:29418/
/http://gerrit.example.org:8080/
/http://UserName@gerrit.example.org:8080/
会被自动替换成ssh://username@gerrit.example.org:29418/
.- 其中
insteadof
还支持正则表达式.
也可以手动编辑 .gitconfig
文件:
[url "ssh://username@gerrit.example.org:29418/"]
insteadof = ssh://gerrit.example.org/
insteadof = ssh://gerrit.example.org:29418/
insteadof = http://gerrit.example.org:8080/
insteadof = http://UserName@gerrit.example.org:8080/