ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子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アノテーションとは
最近更新/作成されたページ
- IPv6とは|128bitアドレス・コロン16進表記/::省略・リンクローカル・SLAAC・デュアルスタック NEW 2026-06-22 12:34:44
- MAC アドレスフィルタリングの仕組みと限界 | ネットワーク入門 NEW 2026-06-22 12:19:10
- VPNとは|暗号トンネル・サイト間/リモートアクセス・IPsec/SSL-VPN/WireGuardを解説 NEW 2026-06-22 12:19:10
- WebSocket とは 全二重リアルタイム通信 ws/wss | ネットワーク入門 NEW 2026-06-22 12:17:25
- HTTP/2 とは 多重化・HPACK・バイナリフレーム | ネットワーク入門 NEW 2026-06-22 12:17:25
- Web通信プロトコル入門 HTTP/2・HTTP/3・WebSocket・gRPC・WebRTC | ネットワーク入門 NEW 2026-06-22 12:17:25
- gRPC とは HTTP/2 + Protocol Buffers の高速 RPC | ネットワーク入門 NEW 2026-06-22 12:17:25
- HTTP/3 (QUIC) とは UDP ベースの低遅延 Web 通信 | ネットワーク入門 NEW 2026-06-22 12:17:25
- WebRTC とは ブラウザ間 P2P の音声・映像・データ通信 | ネットワーク入門 NEW 2026-06-22 12:17:25
- 証明書と認証局(CA)とは|X.509・信頼チェーン・DV/OV/EV・失効(CRL/OCSP)を解説 NEW 2026-06-22 12:17:24
- ファイアウォールとは|パケットフィルタ・ステートフル・DMZ・次世代FW(L4/L7)を解説 NEW 2026-06-22 12:17:24
- iptables/nftablesとは|テーブル・チェーン・ルール例・永続化をLinux視点で解説 NEW 2026-06-22 12:17:24
- HAProxy とは frontend/backend と設定例 | ネットワーク入門 NEW 2026-06-22 12:17:24
- TLS/SSLの仕組み|ハンドシェイク・暗号スイート・前方秘匿性・証明書検証をわかりやすく解説 NEW 2026-06-22 12:17:24
- CDN とは エッジキャッシュ・TTL・Cloudflare/CloudFront | ネットワーク入門 NEW 2026-06-22 12:17:24
コメントを削除してもよろしいでしょうか?