Bower install using only https?

GitBowerGit Clone

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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 - Git

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
}

Solution 3 - Git

Worked for me git config --global url."git://".insteadOf https://

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatt MillsView Question on Stackoverflow
Solution 1 - GitSindre SorhusView Answer on Stackoverflow
Solution 2 - GitquickshiftinView Answer on Stackoverflow
Solution 3 - GitMansoor Ul HaqView Answer on Stackoverflow