この記事を作った動機
単に Git で間違ったリモートを設定してしまったときの修正方法の記録をする。
やり方
# 必要に応じて変更したリモートリポジトリにあるブランチ名を確認すること
# リモート先に origin と指定した場合自動選択される。
git branch -a
# * main
# remotes/origin/main
# Remote URL を間違える例
git remote add origin https://url.to.repo/userName/Receipt-OCR-to-CSV-with-PDF.git
git remote -v
# origin https://url.to.repo/userName/Receipt-OCR-to-CSV-with-PDF.git (fetch)
# origin https://url.to.repo/userName/Receipt-OCR-to-CSV-with-PDF.git (push)
# 正しい Remote URL に設定する例
git remote set-url origin gitea@192.168.1.9:userName/Receipt-OCR-to-CSV-with-PDF.git
git remote -v
# origin gitea@192.168.x.x:userName/Receipt-OCR-to-CSV-with-PDF.git (fetch)
# rigin gitea@192.168.x.x:userName/Receipt-OCR-to-CSV-with-PDF.git (push)
参考にしたサイトとか
- Google Gemini
https://gemini.google.com/app (2026年4月19日) - Git - git-remote Documentation
https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-add (2026年4月19日) - Git - git-remote Documentation
https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-set-url (2026年4月19日) - Git - user-manual Documentation
https://git-scm.com/docs/user-manual#managing-branches (2026年4月19日) - Git - git-remote Documentation
https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-set-head (2026年4月19日) - Git - git-branch Documentation
https://git-scm.com/docs/git-branch#Documentation/git-branch.txt--a (2026年4月19日)