Githubを中央リポジトリとしていたプロジェクトがあったんですが、Gitoriousでリポジトリサーバーが出来たのでそっちに移行する事になりました。中央リポジトリが変わると、自分のワーキングツリーのpush先/pull元となる追跡ブランチを、変更しないといけません。
$ git remote set-url origin git@git.example.com:foo/bar.git
最初はgit configで直接かと思ったんですが、ちょっと探してみたらそれ用のコマンドがありました。今回は変更ですが、追跡ブランチの2個目3個目の追加も、このコマンドで出来るっぽいです。
$ git config -l color.status=auto color.diff=auto core.excludefile=~/.gitignore core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* remote.origin.url=git@github.com:kanonji/example.git branch.master.remote=origin branch.master.merge=refs/heads/master $ git remote set-url origin git@git.example.com:foo/bar.git $ git config -l color.status=auto color.diff=auto core.excludefile=~/.gitignore core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* remote.origin.url=git@git.example.com:foo/bar.git branch.master.remote=origin branch.master.merge=refs/heads/master $ git fetch origin The authenticity of host 'git.example.com (xxx.xxx.xxx.xxx)' can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'git.example.com,xxx.xxx.xxx.xxx' (RSA) to the list of known hosts. remote: Counting objects: 121, done. remote: Compressing objects: 100% (24/24), done. remote: Total 73 (delta 40), reused 70 (delta 37) Unpacking objects: 100% (73/73), done. From git.example.com:foo/bar e8f0481..2735978 master -> origin/master
こんな感じで、サーバーが変わったので、sshの認証に使ってる鍵のfingerprintの確認が出ましたが、originのURLを新しい中央リポジトリに変えるだけで、ワーキングツリーはそのまま利用出来ました。
ところで、例用のドメインはexample.comがあるけど、例用のIPってないのかな?
