Just do IT

思うは招く

git stash pop, apply, dropの違い

特にpopapplyの違いがよくわからなかったので公式ドキュメントを読んだ。

Remove a single stash entry from the list of stash entries.

pop

Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of git stash push. The working directory must match the index. Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards.

  • 待避していた変更履歴をstashリストから削除し、作業しているワーキングツリーに戻す

apply

Like pop, but do not remove the state from the stash list. Unlike pop, may be any commit that looks like a commit created by stash push or stash create.

  • 待避していた変更履歴をstashリストから削除せず、作業しているワーキングツリーに戻す

drop

Remove a single stash entry from the list of stash entries.

待避していた変更履歴をstashリストから削除するだけ。ワーキングツリーには変更を戻さない。

結論としては、stashリストから変更を戻したい場合はpopapplyを目的に応じて使い分ければよい。stash listをきれいにしたい場合はdropすればよい。