git Bower 安装仅使用 https?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15669091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bower install using only https?
提问by arootbeer
I am trying to set up Bower on a build server at our organization's data center, but git
's port does not appear to be open on the data center's firewall. I can use the git command line client to clone via https://[repo]
, but not git://[repo]
.
我正在尝试在我们组织数据中心的构建服务器上设置 Bower,但是git
的端口在数据中心的防火墙上似乎没有打开。我可以使用 git 命令行客户端通过 克隆https://[repo]
,但不能使用git://[repo]
.
Is there a switch or preference which will instruct bower to perform git clone using https
rather than the git
protocol?
是否有一个开关或首选项会指示 bower 使用https
而不是git
协议来执行 git clone ?
I've looked at the source, and considered changing the resolution code to replace git://
with https://
, but I figured I'd ask before I go to those lengths.
我已经查看了源代码,并考虑更改解析代码以替换git://
为https://
,但我想在达到这些长度之前我会问。
回答by Sindre Sorhus
You can make git replace the protocol for you. Just run:
您可以让 git 为您替换协议。赶紧跑:
git config --global url."https://".insteadOf git://
to use HTTPS protocol instead of Git.
使用 HTTPS 协议而不是 Git。
回答by quickshiftin
Building on the answer from @Sindre, I wrote a little helper function in BASH which lives in my ~/.bashrc
file. Call it just as you would grunt
, except now it's called nngrunt
. Enjoy!
基于@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
}
回答by Mansoorulhaq Mansoor
Worked for me
git config --global url."git://".insteadOf https://
对我来说有效
git config --global url."git://".insteadOf https://