仅使用https安装凉亭?

我试图在我们组织的数据中心的构建服务器上设置Bower,但git的端口在数据中心的防火墙上似乎没有打开。我可以使用git命令行客户端通过https://[repo]进行克隆,但不能使用git://[repo]

是否有一个开关或首选项,将指示bower使用https而不是git协议执行git克隆?

我已经查看了源代码,并考虑更改分辨率代码,用https://替换git://,但我想在我去那些长度之前,我应该问一下。

71090 次浏览

你可以让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:// < / p >