Bower install using only https?
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]
.
Is there a switch or preference which will instruct bower to perform git clone using https
rather than the git
protocol?
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.
Solution 1:
You can make git replace the protocol for you. Just run:
git config --global url."https://".insteadOf git://
to use HTTPS protocol instead of Git.
Solution 2:
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!
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
}