Video in progress
In what situation does `git stash` help?
When your work is half done and you need to switch to another branch quickly, git stash temporarily sets aside uncommitted changes. Later you bring them back with git stash pop.
📖 Answer
A typical case: you are working on a feature, the code does not even compile yet, and then a bug shows up in prod and you have to make a hotfix from main.
git stash push -m "hisobot filtri, yarim"
git switch main
git switch -c hotfix/null-amount
# ... fix, commit, push ...
git switch feature/report
git stash pop
Useful commands:
git stash list: the list of saved stashes;git stash apply stash@{1}: apply without deleting;git stash -u: also stash untracked (new) files. Without it, new files stay on disk.
Keeping a stash for long is a bad habit: after a week you will forget what it was. If you need it for longer, it is better to make a plain WIP commit and leave it on a branch.
Sign up to mark studied questions and save your progress.