kikukawa's diary

都内で活動するシステムエンジニアが書いてます。 興味を持った技術やハマったポイント、自分用メモをつけてます。 最近はweb中心

Gitでsubmoduleのurlを変更する

自分用メモ

サブモジュール内で下記のようになっているものを

bash-3.2$ git remote -v
origin  git:/path/to/repo.git (fetch)
origin  git:/path/to/repo.git (push)

下記に変更したい場合

bash-3.2$ git remote -v
origin  ssh://git/path/to/repo.git (fetch)
origin  ssh://git/path/to/repo.git (push)

親となっているリポジトリで、.gitmodulesを編集
urlの部分を新しくしたいurlに変更する

vi .gitmodules

このままでは、親リポジトリのほうで認識できていないのでsyncで教えてあげる。
すると、親リポジトリの .git/configの中も変わる。

git submodule sync

参考
http://stackoverflow.com/questions/913701/changing-remote-repository-for-a-git-submodule