DEV Community

Debugging Rabbit
Debugging Rabbit

Posted on

1

Understanding Git Stashes

Stash is something stored or hidden away for later use.
Why would i want to use git stash in the first place.

let's say i'm working on the sign up button for a client but he needs work done on the login feature immediately regardless of the urgency for the signup feature, i can quickly stash my signup as work in progress [saving it for some moments before i get back] and start working on the login feature.

Git stashing is keeping files [save files] that you are not ready to use yet [not ready to commit].

Save a stash

git stash
Enter fullscreen mode Exit fullscreen mode

save a stash with a name (recommended)

git stash save wip_login_feature
Enter fullscreen mode Exit fullscreen mode

List Your Stashes

git stash list
Enter fullscreen mode Exit fullscreen mode

This will show you a list of all your stashed changes, with their corresponding stash IDs. For example:

stash@{0}: On master: readme_work
stash@{1}: On master: index_html_in_progress 
stash@{2}: WIP on master: 049d078_Create_index_file
Enter fullscreen mode Exit fullscreen mode

Applying a Specific Stash
To apply a specific stash, you can use the git stash apply command and provide the stash ID as an argument:

git stash apply stash@{1}

Enter fullscreen mode Exit fullscreen mode

This will apply the changes from the stash with ID stash@{1}, which in the example above is the "index_html_in_progress" stash.

Popping a Specific Stash
Alternatively, you can use the git stash pop command to apply and then remove a specific stash not needed again:

git stash pop stash@{0}
Enter fullscreen mode Exit fullscreen mode

This will apply the changes from the most recent stash (stash@{0}) and then remove it from the stash list.

Dropping a Specific Stash
If you no longer need a particular stash, you can remove it from the stash list using the git stash drop command:

git stash drop stash@{2}
Enter fullscreen mode Exit fullscreen mode

This will remove the stash with ID stash@{2} from the list of stashes.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay