Menu

How to Use Git Stash Step by Step
📰

How to Use Git Stash Step by Step

DEV Community: beginners·Lavkush Kumar·1 day ago
#GR4geKS4
#devtobeginners#devto#dev#stash#work
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.