How can I temporarily set aside tracked edits with Git stash?
Quick answer
Review the repository with git status, then save tracked edits with git stash push -m "short description". Check git stash list and inspect the newest entry with git stash show stash@{0}; then run git status again. By default, stash omits untracked files, so check whether you have any. A stash is temporary storage, not a durable backup or a replacement for a commit. [S1][S2]
The question, the details, the next step.
A practical checklist
Run
git statusand identify the tracked edits you intend to set aside.Notice any untracked files; add
--include-untrackedif you want them in the stash.Create a named entry with
git stash push -m "[short task description]".Inspect
git stash listandgit stash show stash@{0}to check the entry.Run
git statusagain, and use a commit or separate backup for durable preservation.
A few more useful answers
Does a basic `git stash push` include untracked files?
No. By default, untracked files are not included. Use --include-untracked if you want the stash to capture them too. [S1]
Does a clean `git status` prove that everything was saved?
No. Status helps check tracked changes and normally shows untracked files, but ignored files are not shown unless requested. Inspect the stash as well, and account separately for files status does not display. [S2]
Is a stash a backup?
Treat it as temporary storage for Git work, not as a durable backup. The documentation describes stash as a temporary mechanism and does not establish it as a backup. [S1]
Sources
References used for this guide.
- [S1] Git: git-stash documentation git-scm.com · Checked
- [S2] Git: git-status documentation git-scm.com · Checked
