I've been working as a developer for a couple of years, mainly using C# and Visual Studio. I'm the only one in my company who regularly uses Git stashes to save my progress when I'm switching branches without committing. I avoid WIP commits because I feel they clutter the project, especially when my code isn't ready yet or is full of 'to do' notes, so I stash instead. I'm usually fine with it, but every time I stash a bunch of changes, I worry something might go wrong and I could lose my work. Are there any major issues or stories out there about using stashes? Or should I be as worried about losing changes as I would be if I made a bad commit?
4 Answers
Yeah, stashes can indeed be a bit scary if you're unsure about them. The biggest risk really comes from forgetting about them entirely. I tend to do at least one WIP commit a day to ensure I don’t lose anything. Using stashes is fine as a quick fix, but for longer-term changes, committing to a branch is definitely the way to go.
I used to stash a lot too, but nowadays I prefer using worktrees. They allow you to easily manage multiple branches without the hassle of remembering stashes. If you're only using them occasionally, they're fine, but for ongoing projects, maybe keep that WIP commit habit and squash later.
I share your concerns but honestly, I use stashes a lot and I've never lost anything important. Sure, sometimes you might hit issues with untracked files when applying a stash, but as long as you're careful and don’t forget about your stashes, you're golden. I usually stash if I need to quickly switch branches, but I often use WIP commits when I'm working on bigger changes just to keep a record.
Stashing is pretty safe! Git can hold a ton of stashes without issues, like a junk drawer full of assorted projects. Just keep in mind that you can accidentally lose them if you ever run `git stash clear` or `git stash drop`. As long as you remember to apply your stashes when you're back on your branch, you should be fine. Just make sure you're not relying on stashes for long-term storage; if you need to save your work for more than a day, consider making a WIP commit instead.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String