我正在尝试在我们组织的数据中心上的构建服务器上安装Bower,但是据我观察,git
端口未在数据中心的防火墙上打开。我可以使用git命令行客户端通过https://[repo]
进行克隆,但无法使用git://[repo]
。
是否有一种开关或首选项可以指示bower使用https
而不是git
协议执行git clone操作?
我已经查看了源代码,并考虑更改解析代码以将git://
替换为https://
,但在采取这些措施之前,我想先询问一下。
我正在尝试在我们组织的数据中心上的构建服务器上安装Bower,但是据我观察,git
端口未在数据中心的防火墙上打开。我可以使用git命令行客户端通过https://[repo]
进行克隆,但无法使用git://[repo]
。
是否有一种开关或首选项可以指示bower使用https
而不是git
协议执行git clone操作?
我已经查看了源代码,并考虑更改解析代码以将git://
替换为https://
,但在采取这些措施之前,我想先询问一下。
你可以让 Git 为你替换协议。只需运行以下命令:
git config --global url."https://".insteadOf git://
使用HTTPS协议替代Git。
git config --global --unset url."https://".insteadOf
。请注意,翻译文本应保证准确传达原意,同时简化措辞以使其易于理解,但不应添加额外的解释或信息。 - ryan_effectiveui--global
参数,这将把配置添加到本地的 .git/config
文件中。 - agentofuser在@Sindre的解答基础上,我写了一个小帮手函数在BASH中,存在于我的~/.bashrc
文件中。像使用grunt
一样调用它,只不过现在它叫做nngrunt
。享受它吧!
function nngrunt
{
# Add a section to the global gitconfig file ~/.gitconfig that tells git to
# go over http instead of the git protocol, otherwise bower has fits...
# See https://dev59.com/FGUo5IYBdhLWcg3w7S-T
git config --global url."https://".insteadOf git://
# Run grunt w/ any supplied args
grunt "$@"
# Now cleanup the section we added to the git config file
# Of course we have our own extra cleanup to do via sed since the unset command
# leaves the section around
# See http://git.661346.n2.nabble.com/git-config-unset-does-not-remove-section-td7569639.html
git config --global --unset url."https://".insteadOf
sed -i 's/\[url "https:\/\/"\]//' ~/.gitconfig
sed -i '/^$/d' ~/.gitconfig
}
对我有用
git config --global url."git://".insteadOf https://