余白の書きなぐり

aueweのブログ

http 接続できない環境で github から clone して neobundle を使う

http 接続できない環境で github にアクセスする方法を学んだのでメモ。 もし ssh接続が可能なら、githubからリポジトリをcloneできる。 そういう厳しい環境で neobundle を使う方法についてもメモ。

git clone できない悲しみ

$ git clone http://github.com/Shougo/neobundle.vim.git
Cloning into 'neobundle.vim'...
fatal: unable to access 'http://github.com/Shougo/neobundle.vim.git/'
     : Failed connect to github.com:443; Operation now in progress

解決法

まず github アカウントを作成して ssh鍵 (~/.ssh/id_rsa.pub とか) を登録する。

これで

$ git clone git@github.com:Shougo/neobundle.vim.git

が通るようになる。

次に ~/.gitconfig

[url "git@github.com:"]
  insteadOf = git://github.com/
  insteadOf = https://github.com/
  insteadOf = http://github.com/

と追記する。これで

$ git clone http://github.com/Shougo/neobundle.vim.git

が通るようになった。めでたしめでたし。

蛇足 neobundle を使う場

neobundle を使うだけなら ~/.gitconfig を編集する必要は無い。 とにかく neobundle.vim さえ手に入れれば、 以下のように .vimrc を設定することで vimプラグインがインストールされる。 要するに
NeoBundle 'thinca/vim-quickrun' ,{'type__protocol' : 'ssh' }
とすればよい。

" NeoBundle 'thinca/vim-quickrun'
"
" と書くと https で通信するのでエラーが出る
" [neobundle/install] (10/29): |vim-quickrun|
" git clone --recursive https://github.com/thinca/vim-quickrun.git
" ...
" Cloning into '/home/myname/.vim/neobundle/vim-quickrun'...
" fatal: unable to access 'https://github.com/thinca/vim-quickrun.git/'
"      : Failed connect to github.com:443; Operation now in progre

NeoBundle 'thinca/vim-quickrun' ,{'type__protocol' : 'ssh' }

" と書けば ssh が使用される。
" [neobundle/install] (10/29): |vim-quickrun|
" git clone --recursive git@github.com:thinca/vim-quickrun.git