16
2

How to Save Multiple Drafts in Git: A Guide to Using Stash

4mon 7d ago by programming.dev/u/canpolat in git@programming.dev from www.freecodecamp.org

In my experience unless you are pretty much immediately popping the stash it's much better just to make a branch and do a normal commit. I would recommend avoiding git stash in general.

This sounds all well and good. But I find in practice it never works very well. Too easy to gain a conflict which then messes with the stash (things remain in the stash and need to be dropped if you remember to). I always found it a pain to manage.

These days I just commit everything to master. When I start work on one feature to realise I need something else or to refactor something else first the I do that work, patch commit the changes, create a branch and checkout a new worktree, cherry pick the changes and push that branch to create a pull request. Then continue with the previous work while I wait to get the previous work merged.

Have a script which basically lets me do all that with a single command. And I never need to manage the stash. The only time I use the stash is with a rebase or pull etc with the --auto-stash flag. Which pops things off when it's done anyway. The stash only really works for very temporary stuff like that.