Git stash
Definition
Git stash temporarily sets aside local changes so that work can continue with a clean working state.
Git stash saves the state of local changes including the index in a separate stash and resets the corresponding working areas. The changes can be reapplied later. Which unversioned or ignored files are included depends on the options used.
Simply explained
You temporarily set aside unfinished work and bring it back into your working environment later.
Why it matters in practice
This facilitates short-term task switching without having to immediately commit unfinished changes as a regular project commit to a branch.
Example from business
Possible example: A developer stashes her unfinished adjustment, checks an urgent bug, and then reapplies the stash.
Limits and pitfalls
- A stash is not an independent backup. Conflicts can arise when reapplying; unversioned files are not automatically included without appropriate options.
Origin & history
Stash complements regular commit work with local interim states. It serves short-term task switching and not long-term exchange of a project version.
Use in mid-sized companies
- A team uses labeled stashes for short interruptions and promptly transfers permanent work into traceable commits on appropriate branches.
Frequently asked questions
Do apply and pop differ?
Yes. apply leaves the stash intact; pop tries to apply it and removes it upon successful application.
Sources
- git-stash. · Git-Projekt (o. J.): git-stash.
Editorially reviewed on: