【Git】git remote add origin “リポジトリURL”のエラー【fatal: remote origin already exists.】


みなさんこんにちは!
カミ@god48_です。
みなさんGitの知識はありますか?
この記事はGitとのエラーのgit remote add origin “リポジトリURL”について聞いたことはあるけど、いまいちgit remote add originについてよく分かってない方や、
remoteやoriginまたgitについての全く知識がない方へgitについての紹介です。
この記事でわかること
- git remote add origin urlのエラー原因
- remote-origin-already-exists原因
- git remote add originのエラー対策
- remote-origin-already-exists対策
この記事を最後まで読めば「git remote add origin urlのエラー原因」から「remote-origin-already-exists対策」までの理解が深まりますので、最後まで読んで「git」についてマスターしましょう。

それでは順に見ていきましょう。
プログラミングのエラー時にする事
- エラーが起きる前に動いていた最後の場所を確認する。
- エラーが起きて、処理が止まった場所を確認する。
- エラー文を読む。
- とにかくググる。
今回のエラー分の
git remote add origin “リポジトリURL"
も、必ず前後の処理の部分が存在します。

それでは順に見ていきましょう。
fatal: remote origin already existsの原因

エラー文
git remote add origin “リポジトリURL"
fatal: remote origin already exists.
Google翻訳
致命的:リモートオリジンはすでに存在します。
- すでにgit remote addをしている
- リモートからクローン時に発生することがある
解決方法

それでは解決方法を見ていきましょう。
originを一度削除すれば解決します。

スポンサードサーチ
git remote rm origin
$ git remote rm origin
リモートにあるoriginを削除します。
その後にit remote add origin"リポジトリURL"で再度originにリポジトリURLを追加します。
git remote add origin"リポジトリURL"
git remote add origin"リポジトリURL"
再度、git remote add origin"リポジトリURL"することでコマンドが通るようになります。
スポンサードサーチ
実装やエラーが解決できない場合
プログラミングの実装やエラーでどうしてもわからない場合はメンターに相談するのが一番です。
考えている、見えている範囲が狭くなり、解決から遠くに行って何時間も、何日も経っていることなんてよくある話です。
そういう時は聞ける先輩や、メンターに相談することが大事です。
僕にも相談可能なので気軽に相談してください。

Twitterからの連絡だと確実ですよ。
オンラインスクールやプログラミングスクールといったプログラミングを学べる方法もあるので、そちらもぜひ活用してもいいと思います。
Web開発で分からない時
オンライン完結型スクール DMM WEBCAMP PROアプリ開発で分からない時
プログラミング×稼げる副業スキルはテックキャンププログラミングについて分からない時
RUNTEQ(ランテック)
僕への個人でもメンターでも、スクールでもお好きな方を活用ください。