我正在尝试在我们组织数据中心的构建服务器上设置 Bower,但 git
的端口似乎没有在数据中心的防火墙上打开。我可以使用 git 命令行客户端通过 https://[repo]
进行克隆,但不能通过 git://[repo]
。
是否有一个开关或首选项会指示 bower 使用 https
而不是 git
协议执行 git clone?
我查看了源代码,并考虑更改解析代码以将 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://
不定期副业成功案例分享
git config --global --unset url."https://".insteadOf
--global
,它会将配置添加到本地.git/config
。