我正在尝试在我们组织的数据中心的构建服务器上设置Bower,但git
的端口似乎没有在数据中心的防火墙上打开。我可以使用git命令行客户端通过https://[repo]
克隆,但不能使用git://[repo]
。
是否有一个开关或偏好将指示bower使用https
而不是git
协议执行git克隆?
我查看了源代码,并考虑更改分辨率代码以用git://
替换https://
,但我认为在我达到这些长度之前我会问。
你可以让git替换你的协议。赶紧跑:
git config --global url."https://".insteadOf git://
使用HTTPS协议而不是Git。
在@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 http://stackoverflow.com/questions/15669091/bower-install-using-only-https
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://