glossaryGit Stash
A git feature that temporarily shelves uncommitted changes (both staged and unstaged) so you can work on something else, then reapply them later.
explanation
Git stash records the current state of the working directory and index in a stack-like data structure, then reverts them to the clean HEAD state. This is useful when you need to switch branches urgently (e.g., to fix a production bug) but have uncommitted work in progress that is not ready to commit. Changes are saved to a stash stack. You can have multiple stashes, each identified by a reference like stash@{0}, stash@{1}, etc. Each stash entry optionally includes a message (git stash push -m "message") for identification. The most recent stash is always stash@{0}. Common operations include git stash push (save changes), git stash pop (apply and remove the top stash), git stash apply (apply without removing), git stash list (view all stashes), and git stash drop (remove a specific stash). Stashing only tracks tracked files by default; untracked files require the --include-untracked flag, and ignored files require --all.
examples
git stash push -m 'WIP: refactoring auth middleware'git stash pop # apply and remove the latest stashgit stash list # list all stashesgit stash show stash@{1} # show diff of a specific stashgit stash branch new-feature stash@{0} # create a branch from a stashhow git-agent helps
git-agent encourages committing early and often by making commit creation fast and low-effort. Instead of stashing work-in-progress to switch context, you can let git-agent create a meaningful atomic commit from your current changes, reducing the need for stashes and the risk of forgetting about them.
brew install gitagenthq/brew/git-agentFAQ
What is the difference between git stash pop and git stash apply?Can I recover a dropped stash?Does git-agent stash changes before splitting?