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
Top comments (10)
Yeah, you jumped in to correct me and then tell me I am doing Git wrong without understanding the point of the article and then ignored me when I said your were not understanding the point I was trying to make. Now that you have expanded past just telling me I am wrong, you appear to think I am saving a file change and need to commit it, which is not the point. The point of the article is how to easily recover from a bad git command to an existing commit that the "backup" branch is pointing at already.
Points of advice: I have no idea who you are and I have no reason to take you at your word that you know git better than me. I don't even know what you are actually suggesting because your comments are too vague and don't line up with any git workflow I have ever heard of.
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
I am unclear how that is any easier