An easy safety in git

kwstannard

Kelly Stannard

Posted on May 3, 2022

An easy safety in git

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
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
kwstannard
Kelly Stannard

Posted on May 3, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related