【转】[Git] git config --global url."https://".insteadOf "git://"
来自:kimi.com
关于 git config --global url.<base>.insteadOf <other> 的作用
这个命令用于设置 Git 的 URL 替代规则,允许你将一个较长的 URL 替换为一个较短的别名。这在某些情况下可以简化 Git 操作,尤其是当需要频繁使用某个特定的远程仓库时。
命令格式
bash复制
git config --global url."<base-url>".insteadOf "<other-url>"
示例
假设你经常需要克隆或推送代码到 GitHub 的某个仓库,但觉得
https://github.com/ 这个 URL 太长,你可以设置一个简短的别名,比如 gh:bash复制
git config --global url."https://github.com/".insteadOf "gh://"
这样,当你运行以下命令时:
bash复制
git clone gh://username/repo.git
Git 会自动将其解析为:
bash复制
git clone https://github.com/username/repo.git
浙公网安备 33010602011771号