未ステージ変更を持ったままpullしたいとき
.claude/settings.local.jsonのような自動更新されるファイルがあると、未ステージ変更(=まだgitの索引に登録されていない変更点)がgit pull --rebase(=リベース方式でリモートの変更を取り込むpull)をブロックする。そのファイルだけをstash(=変更を一時的に退避する操作)し、pullしてから元に戻せばよい。
手順
git stash push -m "tmp" <ファイル>— 邪魔なファイルだけをstashするgit pull --rebase— これでrebaseつきpullが通るようになるgit stash pop— stashからファイルを復元する
ポイント
- 全体を退避する必要はない。
stash pushに単一のファイルを指定すればよい pop時に競合(=同じ箇所への変更がぶつかること)が出たら、続行する前に手動で解決する- どうせコミットしないファイルなら、
.gitignoreに追加するほうが根本的な解決になる
考え方
エラーメッセージは敵ではなく、次の一手へのヒントである。「未ステージの変更あり」を見た瞬間にstashパターンを思い出せれば、作業の流れは止まらない。
出典・参考
- git-stash documentation — 公式ドキュメント(Git)
- git-pull --rebase — 公式ドキュメント(Git)
- Pro Git: Stashing and Cleaning — 書籍(Scott Chacon & Ben Straub)
関連ノート
- Agentic Commerce — ACP and Visibility into Being 'Bought by AI'
- browser-to-api — a Browserbase skill that turns a site into OpenAPI from a CDP trace
- Safe tenant-scoped writes to a cloud database — connection, authentication and RLS in one go
- Cloudflare Wrangler and Pages Functions — the deployment tool and the Functions bundle
- Introduction to the Digital Architect (00) — the reality of the profession and the big picture of an original textbook series
- The textbook for becoming a digital architect — table of contents (learning roadmap)