DEV Community

Discussion on: Learn the hidden feature in Git - Stash

Collapse
 
baalkikhaal profile image
Sreekar Guddeti

Thank you for the helpful use case. After reading your write up and doing some look-up of git stash --help, I get a feeling that git stash and its extensions are aliases to block commands consisting of primitive git commands (like add , branch , commit, checkout, reset.

Following up the interrupted workflow use-case in the help man-page

git stash push
Enter fullscreen mode Exit fullscreen mode

is an alias for

(main) $ git branch my_wip
(main) $ git checkout my_wip
(my_wip) $ git add .\n
(my_wip) $ git commit -m 'WIP'
Enter fullscreen mode Exit fullscreen mode

where wip stands for Work in Progress, and

git stash pop
Enter fullscreen mode Exit fullscreen mode

is an alias for

(main) $ git checkout my_wip
(my_wip) $ git reset --soft HEAD^
(main) $ git checkout main
(main) $ git branch --delete my_wip
Enter fullscreen mode Exit fullscreen mode

So considering these boilerplate commands one has to type for an interrupted workflow, there definitely is some utility for using git stash push/pop :).

Some comments have been hidden by the post's author - find out more