🌟

開発中にGithubのリポジトリ名を変更する手順

2021/01/07に公開

①Github上でリポジトリ名を変更

②ローカル環境でGitリモートを更新

"git remote -v"で作業前後を確認しつつ、
"git remote set-url origin [新しい名前]"でGitリモートを更新。

masa@DESKTOP-0CNPS43:~/environment/RailsTutorial_toyapp$ git remote -v
heroku  https://git.heroku.com/masa-rails-tutorial-toyapp.git (fetch)
heroku  https://git.heroku.com/masa-rails-tutorial-toyapp.git (push)
origin  https://github.com/MASA20201203/RailsTutorial.git (fetch)
origin  https://github.com/MASA20201203/RailsTutorial.git (push)
masa@DESKTOP-0CNPS43:~/environment/RailsTutorial_toyapp$ 
masa@DESKTOP-0CNPS43:~/environment/RailsTutorial_toyapp$ git remote set-url origin https://github.com/MASA20201203/RailsTutorial_toyapp
masa@DESKTOP-0CNPS43:~/environment/RailsTutorial_toyapp$ 
masa@DESKTOP-0CNPS43:~/environment/RailsTutorial_toyapp$ git remote -v
heroku  https://git.heroku.com/masa-rails-tutorial-toyapp.git (fetch)
heroku  https://git.heroku.com/masa-rails-tutorial-toyapp.git (push)
origin  https://github.com/MASA20201203/RailsTutorial_toyapp (fetch)
origin  https://github.com/MASA20201203/RailsTutorial_toyapp (push)

更新できたけど、お尻に".git"がついてないのが気になる。
貼り付けたURLはトップバーからコピペしたものだけど、Github上のCodeでコピーしたURLで再更新。

masa@DESKTOP-0CNPS43:~/environment/RailsTutorial_toyapp$ git remote set-url origin https://github.com/MASA20201203/RailsTutorial_toyapp.git
masa@DESKTOP-0CNPS43:~/environment/RailsTutorial_toyapp$ 
masa@DESKTOP-0CNPS43:~/environment/RailsTutorial_toyapp$ git remote -vheroku  https://git.heroku.com/masa-rails-tutorial-toyapp.git (fetch)
heroku  https://git.heroku.com/masa-rails-tutorial-toyapp.git (push)
origin  https://github.com/MASA20201203/RailsTutorial_toyapp.git (fetch)
origin  https://github.com/MASA20201203/RailsTutorial_toyapp.git (push)

無事完了。

参考

Qiita『gitのremote urlを変更する(レポジトリ移行時)』

Discussion