Temporarily Shelving an Uncommitted Experiment
Git can save certain working-tree and index changes for later use while another task uses the same checkout.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Decide what must be captured
A tracked edit and an untracked scratch file may need different stash options. Check which files the shelving operation included before assuming a clean working area. The working tree and index describe the separate states.
Expect changes after restoration
If the base changed while the experiment was shelved, restoring may conflict or require adaptation. Compare the resulting diff and rerun the relevant behavior before resuming work.[1]
Inventory the working files that need to survive
A tracked source edit and an untracked fixture may both belong to an experiment. A default stash typically records tracked changes. Saving untracked files requires the corresponding option or another preservation method. Inspect the proposed saved state before moving away. See working tree and index.
Before: tracked edit plus new fixture
Decide which files to include in saved work
After switching back: apply and inspect the returned changes
Conflicts can require resolution when the base changed
Keep the saved entry until recovery is confirmed
Applying a stash while retaining it lets you verify that the expected files returned before discarding the saved reference. Check staged state when that distinction matters. Avoid assuming ignored build output is part of a default save.