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

https://www.freecodecamp.org/news/how-to-save-multiple-drafts-in-git-a-guide-to-using-stash/

16 points · 2 comments · view on lemmy.world

2 Comments

FizzyOrange@programming.dev · 4 pts · 182d

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.

nous@programming.dev · 1 pts · 182d

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.