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.


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
2025 jamb cbt expo/answers /jamb cbt answers /2025 jamb answer. Learning and information management life skills.