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
save a stash with a name (recommended)
git stash save wip_login_feature
List Your Stashes
git stash list
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
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}
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}
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}
This will remove the stash with ID stash@{2} from the list of stashes.