Git リモートリポジトリ URL の変更
リモートリポジトリ URL を変更する
既存のリモートリポジトリ URL を変更するには、git remote set-url コマンドを使う。
接続されている Git リポジトリを確認する
変更する前に、現在のローカル Git リポジトリがどのリモートリポジトリと接続されているかを、次のように git remote -v で確認できる。
$ git remote -v
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
接続されている Git リポジトリを変更する
確認後、次の形式でコマンドを入力するとリモートリポジトリ URL が変更される。
git remote set-url origin <変更するリモートリポジトリ URL>
実行例は次のとおりである。
$ git remote set-url origin https://github.com/user/repo2.git
2 つの引数を持つ。
origin: 既存のリモートリポジトリ名。https://github.com/user/repo2.git: 新しく変更するリモートリポジトリ URL。