So, everyone's git right of passage is to nervously try to run a git command and then realize with horror that you just lost your work on your local repo. Then you run to google and try to find out how to reverse what you just did and run some archaic commands to find the lost commits.
With a small amount of foresight, you can just create a new branch called "backup" pointing to your work and reset back to it if necessary.
$ git branch -C backup
# mess up your git branch
$ git reset backup --hard
# good to go
Discussion (6)
Why make a branch when you can just commit? Merges can be undone as well.
I am unclear how that is any easier
Not easier but better. You're using GIT wrong.
The whole point of commits is they're save points. You don't need 300 branches. Branches are to separate incomplete features.
If you want to save a solid point then you MERGE into your master / main branch from develop, but don't branch to save work.
PLEASE don't ever do this professionally.
I feel like maybe you are leaping to conclusions about what I am trying to do here. I am not even talking about develop or main. This is about doing stuff locally.
I am not sure where you got 300 branches from either
Nope
Wasn't try to be mean. Just that isn't the proper way to use GIT. Doesn't make sense.
You can have master and develop branches locally. I branch locally all the time.