TFW when you do a git reset HEAD --hard because nothing works anymore for unknown reasons, and the moment you press Enter, you realize that you havent committed or pushed any of your work for the last three days or so...

  • 2

    That's horrible
  • 2
    1. Don't *ever* reset hard, that's a bad idea. There are several better ways.
    2. You really should commit more often, but I get it, habits are hard. Maybe this'll teach you :'(
    3. If you don't want to learn a habit, I recommend modifying your PS1 variable to include the status of the current folders git repo. There are some really neat bash/zsh/ksh/whatever scripts for you to have some symbols at the end of your prompt. I added some a few years back, can't do without it now.

    Mine uses ! For uncommitted changes, + for new files, * for unpushed refs, - for deletion, and has the branch name at the end, and I love it!
  • 2
    @taigrr What would be a better method if you fucked up and dont know why or how?

    Also would you mind sharing your PS1 String (or however youd call that)?
  • 0
    We all learn this, then we push it deep deep down and deny deny deny.

    Better git gud :/
  • 0
    Dear God, i was about to fall a sleep and then i read this horror story...
  • 0
    @gathurian sure.

    So the first answer is "commit more, rebase later". That way if you screw up it's easy to fix.

    Of course, that doesn't always work. If you want to just go back for a bit, look into git stash and git stash pop. They are probably pretty close to what you're already doing but are much safer.

    As to my PS1, I haven't gotten around to publishing a public one yet, but here's some of the git bits in my shell: https://ipfs.io/ipfs/...

    Adding shell coloring is easy, a matter of escape sequences etc. to the if/fi blocks.

    To use it, stick it in your home directory, in a file called .bash_PS1 and then put "source ~/.bash_PS1" in your .bashrc

    Hope that helps.
  • 0
    damn, I did a reset -hard recently in a moment of shear panic and lost 3 commits, never using that again unless absolutely necessary
Your Job Suck?
Get a Better Job
Add Comment