0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

リポジトリ名つけ間違えた!GitHubで名前を直す方法とその後の対応

Posted at

はじめに

GitHub で Git 管理しているリポジトリの名前を変更したくなったときの手順をまとめました。
特に、ローカルとの接続が切れて push できなくなる場合もあるので注意が必要です!

今回の目標

Go-practice-となぜかハイフン付きでリポジトリを命名してしまいました。
落ち着かないので、go-practiceへ変更してみます。

作業手順

GitHub(Web)での作業

  1. 対象リポジトリページを開きます。
    例: https://github.com/ユーザー名/Go-practice-
  2. メニュー右上から「Settings」をクリックします。
  3. Repository name 欄に変更後の名前(ここではgo-practice)を入力し、「Rename」ボタンをクリックします。
    スクリーンショット 2025-07-25 234447.png
  4. 完了!
    URL が https://github.com/ユーザー名/go-practice に変わりました!
    スクリーンショット 2025-07-25 235527.png

ローカルでの対応

リポジトリ名を変更すると、リモート URL も変わるため、ローカル設定の変更も必要です。

  1. 対象のプロジェクトフォルダに移動します。

    cd ~/your-project-folder
    
  2. 現在のリモート URL を確認します。

    git remote -v
    

    出力例(SSH の場合):

    origin  https://github.com/ユーザー名/Go-practice-.git (fetch)
    origin  https://github.com/ユーザー名/Go-practice-.git (push)
    
  3. 新しいリポジトリ名に合わせ、URL を変更します。

    HTTP 接続の場合

    git remote set-url origin https://github.com/ユーザー名/新しいリポジトリ名.git
    

    SSH 接続の場合

    git remote set-url origin git@github.com:ユーザー名/新しいリポジトリ名.git
    

おわりに

リポジトリ名を変更すると、URL も変わって push や pull ができなくなることがありますが、
git remote set-url コマンドで簡単に対応できます。

入力ミスや命名ミスに気づいたときでも、落ち着いて対応すれば大丈夫です!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?