ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球
子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール
親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
| この記事の要点 |
|
このエラーの概要
git コマンドを実行したときに表示される、最も基本的なエラーの一つです:
# パターン1: カレントが git 管理下じゃない
$ git status
fatal: not a git repository (or any of the parent directories): .git
# パターン2: リモート操作
$ git push origin main
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
# パターン3: クローン時
$ git clone git@github.com:user/typo-repo.git
Cloning into 'typo-repo'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
# パターン4: SSH 認証失敗
$ git pull
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
つまり 「ここは git リポジトリじゃないか、リモート先のリポジトリが見つからない」 と git が訴えています。原因は複数あるので順番に切り分けます。
原因の切り分けフロー
| シナリオ | 切り分けコマンド | 対処 |
|---|---|---|
| ローカルが git 管理下でない | ls -la .git | git init(対処1) |
| origin 未設定 | git remote -v | git remote add origin URL(対処2) |
| URL タイポ | git remote get-url origin | git remote set-url(対処3) |
| SSH 鍵未登録 | ssh -T git@github.com | 鍵登録(対処4) |
| 権限不足 | ブラウザで該当 URL を開く | 招待 / トークン更新(対処5) |
| VPN/プロキシ | ping git.internal / curl -I URL | VPN 接続(対処6) |
対処1: ローカルディレクトリが git 管理下でない
# まず現在地と .git の有無を確認
pwd
ls -la | grep .git
# 親ディレクトリにも .git が無いか
git rev-parse --show-toplevel
# fatal: not a git repository (or any of the parent directories)
# → どこにも無い
# 新規 git リポジトリにする場合
git init
git add .
git commit -m "Initial commit"
# 既存リポジトリをクローンしたい場合
cd ..
git clone https://github.com/user/repo.git
cd repo
対処2: origin が未設定 / 別名で登録されている
# リモート一覧
git remote -v
# (何も表示されない → origin 未設定)
# origin 追加
git remote add origin https://github.com/user/repo.git
# 確認
git remote -v
# origin https://github.com/user/repo.git (fetch)
# origin https://github.com/user/repo.git (push)
# 初回 push(上流ブランチ設定込み)
git push -u origin main
対処3: リモート URL のタイポ修正
# 現在の URL
git remote get-url origin
# URL を書き換え
git remote set-url origin git@github.com:correct-user/correct-repo.git
# 別名リモートを追加
git remote add upstream https://github.com/original/repo.git
# 不要なリモート削除
git remote remove old-origin
# HTTPS ↔ SSH 切替
# HTTPS → SSH
git remote set-url origin git@github.com:user/repo.git
# SSH → HTTPS
git remote set-url origin https://github.com/user/repo.git
対処4: SSH 鍵が未登録
Permission denied (publickey) が併発する場合:
# 既存鍵を確認
ls -la ~/.ssh/
# 無ければ生成 (ed25519 推奨)
ssh-keygen -t ed25519 -C "you@example.com"
# 保存先はデフォルト Enter で OK
# passphrase は CI なら空でも可
# 公開鍵を GitHub Settings → SSH and GPG keys に貼り付け
cat ~/.ssh/id_ed25519.pub
# ssh-agent に追加
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# 疎通テスト
ssh -T git@github.com
# Hi ! You've successfully authenticated, ...
# SSH 設定で複数アカウント使い分け
cat >> ~/.ssh/config <<'EOF'
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
EOF
対処5: HTTPS / PAT 認証エラー
2021 年 8 月以降、GitHub は HTTPS のパスワード認証を廃止しました。Personal Access Token を使います:
# git の credential 設定
git config --global credential.helper cache
# またはストア永続化(macOS)
git config --global credential.helper osxkeychain
# 初回 push 時にユーザー名とトークン (パスワードの代わり) を入力
git push
# Username: your-github-username
# Password: ghp_xxxxxxxxxxxxxxxxxxxx ← PAT を入力
# URL に直接埋め込む(非推奨:履歴に残る)
git remote set-url origin https://USER:TOKEN@github.com/user/repo.git
# Personal Access Token 作成
# GitHub → Settings → Developer settings → Personal access tokens
# スコープ: repo (private 利用時) / public_repo
対処6: 社内 Git サーバ / VPN / プロキシ
# DNS 解決確認
nslookup git.internal.example.com
# 疎通確認
curl -I https://git.internal.example.com
ping git.internal.example.com
# VPN 接続必要なら接続後に再試行
# プロキシ経由(社内 PC)
git config --global http.proxy http://proxy.example.com:8080
git config --global https.proxy http://proxy.example.com:8080
git config --global http.sslVerify false # 自己署名のみ(非推奨)
# 一時的に無効化
git -c http.proxy= push
初心者がハマる典型パターン
| 状況 | 原因 | 対処 |
|---|---|---|
サブディレクトリで git init したのを忘れている | 親ディレクトリでコマンド実行 | cd でリポジトリ内へ |
| VS Code で「フォルダを開く」したが git 管理外 | .git が無い | Source Control → Initialize Repository |
クローン直後にディレクトリ外で git status | カレントが repo の親 | cd repo |
| Windows でパスの大文字小文字 | git は大小区別する | 正しい URL を貼り直し |
FAQ
Q: git clone したのにすぐ「not a git repository」と言われる
A: クローンしたディレクトリの外で実行しています。cd してから操作してください。
Q: 自分は read 権限あるはずなのに「Repository not found」
A: PAT のスコープが古い可能性。GitHub Settings から PAT を再発行し、repo スコープを付与してください。Organization の SSO 認可も必要なことがあります。
Q: WSL から Windows の git に切り替えたら毎回認証要求
A: git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe" で Windows 側の認証情報を共有できます。
ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子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
コメントを削除してもよろしいでしょうか?