ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球
子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール
親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
| この記事の要点 |
|
このエラーの概要
git remote add origin を実行したときに出ます:
$ git remote add origin https://github.com/user/repo.git
fatal: remote origin already exists.
# 確認すると確かにある
$ git remote -v
origin https://github.com/old-user/old-repo.git (fetch)
origin https://github.com/old-user/old-repo.git (push)
git にとって 「リモート」は名前付きの参照です。origin という名前が既に使われていれば add は失敗します。これは安全機構で、知らずに別 URL に上書きされるのを防いでくれます。
解決パターン3つ
| やりたいこと | コマンド | 備考 |
|---|---|---|
| origin の URL を変えたいだけ | git remote set-url origin | 最も安全。履歴・upstream 維持 |
| origin を消して付け直す | git remote remove origin → git remote add origin | upstream 設定もリセットされる |
| 別名で並行追加 | git remote add upstream | fork 元参照などで定番 |
対処A: set-url で URL だけ変更(推奨)
# 現在の origin URL を確認
git remote -v
git remote get-url origin
# URL を変更
git remote set-url origin https://github.com/new-user/new-repo.git
# SSH ↔ HTTPS 切替
git remote set-url origin git@github.com:user/repo.git
# fetch 用と push 用で別 URL にする (ミラーリング時)
git remote set-url --push origin git@gitlab.internal:user/repo.git
# 確認
git remote -v
# origin https://github.com/new-user/new-repo.git (fetch)
# origin https://github.com/new-user/new-repo.git (push)
# 試しに fetch
git fetch origin
対処B: 削除して付け直し
# remove (rm) でリモート削除
git remote remove origin
# あるいは古い書き方
git remote rm origin
# 確認(何も出ない)
git remote -v
# 改めて追加
git remote add origin https://github.com/user/repo.git
# 初回 push で upstream 設定
git push -u origin main
# upstream 設定だけ後から付けることもできる
git branch --set-upstream-to=origin/main main
対処C: 別名で追加(fork 開発で多用)
OSS の fork 開発では、自分の fork を origin、本家を upstream として両方扱います:
# 自分の fork
git remote add origin git@github.com:my-user/my-fork.git
# 本家を upstream として追加
git remote add upstream https://github.com/original-author/repo.git
git remote -v
# origin git@github.com:my-user/my-fork.git (fetch)
# origin git@github.com:my-user/my-fork.git (push)
# upstream https://github.com/original-author/repo.git (fetch)
# upstream https://github.com/original-author/repo.git (push)
# 本家の最新を取り込む
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
git clone 直後にこのエラーが出るのはなぜ?
git clone は自動的に origin を設定します。そのため clone 直後にもう一度 git remote add origin すると重複エラーになります。
git clone https://github.com/user/repo.git
cd repo
git remote -v
# origin https://github.com/user/repo.git (fetch) ← 既にある
# origin https://github.com/user/repo.git (push)
# ここで以下を実行するとエラー
git remote add origin https://github.com/user/repo.git
# fatal: remote origin already exists.
リモート一覧と詳細表示
# 一覧(URL 付き)
git remote -v
# 名前のみ
git remote
# 詳細
git remote show origin
# * remote origin
# Fetch URL: ...
# Push URL: ...
# HEAD branch: main
# Remote branches:
# main tracked
# Local branch configured for 'git pull':
# main merges with remote main
# Local ref configured for 'git push':
# main pushes to main (up to date)
# 名前変更(origin → upstream に rename したいとき)
git remote rename origin upstream
関連エラーと対処
| エラー | 状況 | 対処 |
|---|---|---|
error: No such remote: 'origin' | 削除済み or 未設定 | git remote add origin URL |
fatal: refusing to merge unrelated histories | 新規リモートに既存ローカルを push | git pull --allow-unrelated-histories origin main |
error: src refspec main does not match any | commit が一つも無い | git add . && git commit -m init |
! [rejected] main -> main (fetch first) | リモートに先行コミットあり | git pull --rebase 後 push |
FAQ
Q: set-url したのに古い URL に push されている
A: --push オプション付きで別 URL を設定した可能性。git remote -v で (fetch) と (push) を両方確認してください。
Q: リモートを丸ごとリセットしたい
A: .git/config を直接編集して [remote "origin"] セクションを削除する手もありますが、git remote remove origin の方が安全です。
Q: GitHub から GitLab に移行したい
A: git remote set-url origin git@gitlab.com:user/repo.git → git push --all + git push --tags で全ブランチとタグを移行できます。
ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球
子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール
親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
子ページはありません
- fatal: remote origin already exists.
- fatal: '~' does not appear to be a git repository
- Cannot rebase: You have unstaged changes. Please commit or stash them.
- remote: error: denying non-fast-forward refs/heads/master (you should pull first)
- error: pathspec ... did not match any file(s) known to git.
- The following untracked working tree files would be overwritten by checkout
- fatal: Not a valid object name: 'master'.
- Unlink of file 'ファイル名' failed. Should I try again? (y/n)
- Another git process seems to be running in this repository, ~
- error: Your local changes to the following files would be overwritten by checkout:
人気ページ
- 1 Eclipseで「サーバーに追加または除去できるリソースがありません。」の原因と対処法
- 2 tomcat の起動 / 停止ログと catalina.log・catalina.out の違い
- 3 JavaScript base URL 取得方法|window.location.origin と SSR/Node.js 対応
- 4 YouTube Data API v3 エラー一覧|403/400/404 の主要原因と切り分け
- 5 Spring Frameworkのアノテーション一覧
- 6 Laravel エラー一覧|500/Blade/DB 接続/ルーティングの代表エラー
- 7 3Dグラフィックスとは|モデリング/レンダリング/主要ソフトウェア (Blender / Maya)
- 8 【Spring】@Valueアノテーションとは
- 9 CATALINA_HOME の確認方法 (Linux / Mac)
- 10 【Spring】@Autowiredアノテーションとは
最近更新/作成されたページ
- Laravel キャッシュクリア完全ガイド(cache:clear / config:clear / 2026-05-18 07:42:07
- プロジェクトの作成と削除 2026-05-18 07:42:07
- インストール直後にNetbeansが反応しない 2026-05-18 07:42:07
- 動画やチャンネルの検索 2026-05-18 07:42:07
- APIキー取得方法 2026-05-18 07:42:07
- チャンネル情報の取得 2026-05-18 07:42:07
- API 入門 — Web API(REST / GraphQL / gRPC / 2026-05-18 07:42:07
- インストール(eclipseプラグイン) 2026-05-18 07:42:07
- Laravel「Dotenv values containing spaces must be surrounded 2026-05-18 07:42:07
- エラー一覧 2026-05-18 07:42:07
- curl: (51) SSL: certificate subject name '~' does not match 2026-05-18 07:42:07
- インストール方法(Windows版) 2026-05-18 07:42:07
- JSONから配列に変換 2026-05-18 07:42:07
- 処理を一定時間待つ 2026-05-18 07:42:07
- A non well formed numeric value encountered 2026-05-18 07:42:07
コメントを削除してもよろしいでしょうか?