til/applied-sciences/engineering/stash-pull-rebase
stash-pull-rebase.mdupdated 2026-07-162093 words
ダブルクリックで英日反転
Applied Sciences · Engineering

Pull while holding unstaged changes: stash → pull → pop

EN

When an auto-updating file like .claude/settings.local.json blocks `git pull --rebase`, stash only that file, pull, then restore it. No need to stash your entire working tree.

The pattern

  • git stash push -m "tmp" <file> — stash only the blocking file
  • git pull --rebase — pull with rebase now succeeds
  • git stash pop — restore the file from the stash

Key points

  • You can name a single file in stash push — no need to stash everything
  • If pop conflicts, resolve manually before continuing
  • If you will never commit the file, adding it to .gitignore is the cleaner long-term fix

Mindset

  • An error message is a hint, not a dead end
  • Recognising the stash pattern the moment you see "unstaged changes" keeps your flow uninterrupted
Stash only what blocks you, pull --rebase, pop — and consider .gitignore for files you never commit.
Applied Sciences · Engineering

未ステージ変更を​持ったまま​pullする​:stash → pull → pop

JP

.claude/settings.local.json のような​自動更新ファイルが​ `git pull --rebase` を​ブロックする​ときは、​その​ファイルだけを​stash​(一時退避)して、​pullして、​元に​戻す。​作業ツリー全体を​退避する​必要は​ない。

手順

  • git stash push -m "tmp" <ファイル> — 邪魔な​ファイルだけを​stash
  • git pull --rebase — rebaseつきpullが​通るようになる
  • git stash pop — stashから​ファイルを​復元する

ポイント

  • stash push に​ファイルを​指定すれば、​全体を​退避しなくて​済む
  • pop時に​競合​(conflict)が​出たら​手動で​解決してから​続ける
  • どうせコミットしない​ファイルなら​ .gitignore に​追加するのが​根本的な​解決策

考え方

  • エラーメッセージは​行き止まりではなく、​次の​一手への​ヒント
  • 「未ステージの​変更​あり」を​見た​瞬間に​stashパターンを​思い出せれば、​フローは​止まらない
邪魔な​ファイルだけstashし、​pull --rebaseし、​popする。​コミットしない​ファイルは​.gitignoreで​根本解決。
148 notestil