ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球
子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール
親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
| この記事の要点 |
|---|
|
エラーの状況
# ブランチ切替で
$ git checkout feature/login
error: pathspec 'feature/login' did not match any file(s) known to git
# ファイル add で
$ git add my-file.txt
fatal: pathspec 'my-file.txt' did not match any files
# ファイル checkout で
$ git checkout HEAD~1 path/to/file
error: pathspec 'path/to/file' did not match any file(s) known to git
パターン別の原因と対処
パターン 1: ブランチ名のタイポ / リモートのみ存在
# ブランチ一覧確認
$ git branch -a
develop
main
* feature/login
remotes/origin/HEAD -> origin/main
remotes/origin/develop
remotes/origin/feature/auth ← リモートのみ
remotes/origin/feature/login
# ローカルにないがリモートにある場合
$ git fetch origin
$ git checkout feature/auth
# → 自動的に remote から tracking branch 作成
パターン 2: 新規ブランチ作成 (-b 忘れ)
# ダメな例
$ git checkout new-branch
error: pathspec 'new-branch' did not match...
# 修正: 新規ブランチなら -b
$ git checkout -b new-branch
Switched to a new branch 'new-branch'
# Git 2.23+ の新コマンド
$ git switch -c new-branch
パターン 3: ファイルパスの誤り
# 大文字小文字違い
$ git add MyFile.txt
fatal: pathspec 'MyFile.txt' did not match any files
$ ls
myfile.txt ← 小文字
$ git add myfile.txt # 修正
# .gitignore に含まれている
$ cat .gitignore
*.log
build/
$ git add build/output.log
fatal: pathspec...
# → .gitignore に書かれているので追跡対象外
$ git add -f build/output.log # 強制追加 (非推奨)
パターン 4: 未取得のリモートブランチ
# 同僚が push したばかりのブランチ
$ git checkout feature/recently-pushed
error: pathspec...
# リモートを更新してから
$ git fetch origin
$ git checkout feature/recently-pushed
# または
$ git checkout -b feature/recently-pushed origin/feature/recently-pushed
パターン 5: タグやコミット ID
# 古いタグ名のタイポ
$ git checkout v1.0
error: pathspec 'v1.0' did not match...
$ git tag -l
v1.0.0
v1.1.0
v2.0.0
$ git checkout v1.0.0 # 正しいタグ名
パターン 6: detached HEAD 後の操作
# 特定のコミットに移動した状態
$ git checkout abc1234
Note: switching to 'abc1234'.
You are in 'detached HEAD' state.
# そこから新ブランチを切らずにファイル変更
$ git add new-file
fatal: pathspec 'new-file'...
# 解決
$ git switch -c temp-branch
# → これでブランチが切られて add 可能
パターン 7: スパースチェックアウト
# sparse-checkout 有効化中
$ git sparse-checkout init
$ git sparse-checkout set src/
# 範囲外のファイルを操作しようとする
$ git checkout HEAD docs/README.md
error: pathspec 'docs/README.md' did not match...
# 対処: sparse 設定を更新
$ git sparse-checkout add docs/
# または無効化
$ git sparse-checkout disable
調査コマンド
# 管理されているファイル一覧 (HEAD basis)
$ git ls-files
src/main.py
src/util.py
README.md
# 特定の名前で検索 (部分一致)
$ git ls-files | grep -i myfile
# git 管理下にない (untracked) ファイル
$ git status
# ブランチとタグ
$ git branch -a
$ git tag -l
# リモートブランチを最新化
$ git fetch --all --prune
# 履歴を遡って特定ファイルが存在したコミット
$ git log --all --full-history -- "path/to/file"
# 削除されたファイルを探す
$ git log --diff-filter=D --summary | grep delete
未追跡ファイルを git に追加
$ git status
On branch main
Untracked files:
(use "git add ..." to include in what will be committed)
new-file.py
$ git add new-file.py
# OK
削除済みファイルを復元
# どのコミットで削除されたか
$ git log --diff-filter=D --summary | grep -A1 "delete mode"
commit abc1234
delete mode 100644 deleted-file.py
# 削除前のバージョンを復元
$ git checkout abc1234^ -- deleted-file.py
$ git add deleted-file.py
$ git commit -m "restore deleted-file.py"
類似エラー
| エラー | 意味 |
|---|---|
pathspec did not match any files | このページ |
did not find any matching ref | ブランチ / タグ参照失敗 |
fatal: not a git repository | git 管理されていないディレクトリ |
You have unstaged changes | 未コミット変更で operation 失敗 |
refusing to merge unrelated histories | 共通祖先がない (--allow-unrelated-histories) |
関連記事
ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子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
コメントを削除してもよろしいでしょうか?