Is Using Git Stashes Safe or Risky?

0
0
Asked By CleverCoder123 On

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

Answered By CodeSlinger99 On

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.

Answered By LazyDeveloper_87 On

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.

Answered By DevDude42 On

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.

Answered By TechieGal88 On

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.