Git Cheat Sheet · Set aside
Set your changes aside
git stash push -u -m <message>
git stash puts your current changes away and restores the working copy to the state of the last commit. You can then switch branches, deal with an emergency, and pick your work back up with git stash pop.
What it does
Stores the current changes in a reserve and cleans up the working copy.
A use case
You need to switch branches for an emergency while your work is not ready to be committed.
On the command line
git stash- Sets aside changes to tracked files.
git stash push -u -m "menu experiment"- Includes untracked files and gives a name.
git stash push <file>- Sets aside only some files.
git stash list- Lists stashes: stash@{0} is the most recent.
git stash show -p stash@{1}- Shows the content of a stash.
In Merathon
- "Stash" button in the toolbar.
- Give a message if you want to find it easily, and check "Include untracked files" if needed.
Frequently asked questions
Does git stash keep new files?
Not by default: add -u (--include-untracked) to include them.
Is a stash shared with the remote?
No, stashes stay on your machine. To share work in progress, commit it on a branch.