LoginSignup
2
1

More than 3 years have passed since last update.

【Git】誤って登録したリポジトリを取り消して、再登録する方法

Last updated at Posted at 2021-04-08

症状

git remote addで誤ったリポジトリを設定してしまい、再度正しいリポジトリを記したコマンドをじっこうするもエラーが表示されてしまいました。

ターミナル
#誤ったリポジトリを設定
git remote add origin https://github.com/ユーザー名/hogeh

#正しいものを再度入力するエラー
git remote add origin https://github.com/ユーザー名/hogehoge
fatal: remote origin already exists.

誤って登録してしまったリポジトリの確認を下記でしました。エラーが出ていたように2度目のコマンドではエラーが出ていたように 設定で上書きはされていないようです。

git -v
origin https://github.com/ユーザー名/hogeh (fetch)
origin https://github.com/ユーザー名/hogeh (push)
```

解決方法

「git remote rm origin」コマンドで登録したリポジトリを削除できました。

ターミナル
git remote rm origin

#登録されているりぽじとりを確認するも何も表示されませんでした(登録が正常に取り消された)
git remote -v

#再度登録しなおしてして確認
git remote add origin https://github.com/ユーザー名/hogehoge

git remote -v
origin  https://github.com/ユーザー名/hogehoge (fetch)
origin  https://github.com/ユーザー名/hogehoge (push)

参考

git remote add を取り消す方法
https://qiita.com/ngtkk/items/05097d127db6a415a7d8

2
1
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
2
1