256

組織のデータ センターのビルド サーバーに Bower をセットアップしようとしてgitいますが、データ センターのファイアウォールで のポートが開いていないようです。git コマンド ライン クライアントを使用して を介してクローンを作成できますhttps://[repo]が、git://[repo].

プロトコルhttpsではなく使用して git clone を実行するように bower に指示するスイッチまたは設定はありますか?git

ソースを見て、解決コードを に変更することを検討しgit://ましhttps://たが、それらの長さに行く前に質問することにしました。

4

3 に答える 3

627

git でプロトコルを置き換えることができます。とにかく走れ:

git config --global url."https://".insteadOf git://

Git の代わりに HTTPS プロトコルを使用します。

于 2013-03-28T14:48:27.020 に答える
2

@Sindre からの回答に基づいて、自分の~/.bashrcファイルにある BASH に小さなヘルパー関数を書きました。と同じように呼び出しますが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
}
于 2015-12-10T22:52:36.820 に答える