Originally published on CodingCush .
Git stash is a temporary shelf for your uncommitted work. Run git stash push and Git stores your changed files safely, then cleans your working folder so you can switch branches or fix something urgent. Later, git stash pop takes the work off the shelf and puts it back. This guide walks through the whole cycle step by step, using a tiny project tested with Git 2.43.
Step 1: Check Your Work with git status
Start with a small project. Create two files, commit them, then change one line in homepage.txt so there is real unfinished work to stash:
git init -b main git add homepage.txt notes.txt git commit -m "Add homepage and notes" git status --short
Enter fullscreen mode
Exit fullscreen mode
Our session began with homepage.txt containing Welcome to my site , then we changed it to Welcome to my site - new hero draft . The status check printed:
M homepage.txt
Enter fullscreen mode
Exit fullscreen mode
The letter M means modified.…