Welcome to the fine art of stash maintenance where you pretend you were working on a feature and not debugging the build for three hours. git stash list
is your inventory command when half finished work needs to be parked and you need to look sane to your future self.
Run git stash list
to see what you have saved. The output gives a numbered stack that looks like a bulletin board for abandoned ideas. Example output might look like this
stash@{0} - WIP on main 9b3f2c Fix layout glitch
stash@{1} - WIP on feature/auth work in progress
stash@{2} - WIP on experiment quick test
Each entry is an index you can reference, like stash@{0} or stash@{1}. Naming stashes with a message makes life less cryptic and helps you avoid applying the wrong pile of code at the worst possible moment.
If you do not want surprises run git stash show -p stash@{0}
to view the full patch. That shows the exact hunks that were saved so you can decide if you want everything or only a part.
If you only need a quick summary use git stash show stash@{0}
which gives a one line diffstat style summary. Use the full patch when you plan to cherry pick hunks or worry about conflicts.
Use these commands based on how tidy you want your stash list to remain
git stash apply stash@{1}
reapplies changes and keeps the stash in the list for latergit stash pop
reapplies the top stash and removes it from the list in one movePop is convenient and slightly reckless if your working tree or index has changes that can conflict. When in doubt apply into a temporary branch and inspect the result.
Create a human readable stash message with a command like
git stash push -m 'WIP feature X'
Named stashes keep git stash list
from reading like a crime scene log. When you finish with a stash remove it with
git stash drop stash@{0}
And if you want dramatic cleanup use
git stash clear
But remember clear deletes everything and there is no undo. This is not optional drama, this is permanent deletion of code you might need.
git stash show -p
git checkout -b temp-restore
git stash apply stash@{0}
and testgit stash drop stash@{0}
git stash apply
if you want to keep a backup copy of the stashgit stash pop
when you are sure and you do not mind cleaning up right awayStashing is not magic, it is a polite lie you tell your repo while you go fix something else. Use git stash list
to keep track, inspect changes with git stash show -p
, and restore carefully with git stash apply
or git stash pop
. Follow these steps and you will avoid the horror of restoring the wrong patch and wondering why the app broke in spectacular fashion.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.