7

Today I did 'git reset --hard'

Didn't go se well. Time to install BackInTime

Comments
  • 1
    You can just checkout old commit, if you have it's sha
    You can het it via some kind of history command
  • 2
    @ravijojila that works when you don't forget to make a commit
  • 1
    @TheBird956 shouldn't you have installed BIT prior to hard resetting? Or is it future mistakes?
  • 2
    @asgs yeah I should have, but wasn't aware it existed. I'm still a bit new with Linux as my development OS
  • 1
    Never did a hard reset before? How do you do your release builds then. I always empty the root folder and do a hard reset to get a really clean build.
  • 1
    Protip: make a copy of the project folder, they try whatever risky business you want inside the copy and check the results.
    If everything went well, push the changes and delete the duplicate folder; otherwise, delete the messed up copy and start over until you get it right.
  • 2
    @endor If you do that, you don't have to use git. Better learn to use git right. Everything that's committed or stashed, can be undone at least until the next garbage collection, as long as the .git folder is ok. For .git folder issues, you better push frequently.

    If one loses more than a few hours of work on a horrible crash or human failure, it's time to optimize the workflow.
  • 4
    Git reset hard only removes uncommited changes, commit early commit often, you can rebase -i later to fix the commit message
  • 1
    Don't screw up.
  • 1
    @ddephor there are some things that even git won't protect you from, such as working with git reflog.

    When trying to find the right strategy for a complex merge, I always make a copy of the project, in case I make any mistake (like copy-pasting the wrong commit sha when trying to undo a failed merge).

    For small stuff, it's faster than actually bothering with pulling from remote and overwriting the local mess. Also avoids the potential need of push --force (in case of some significant branch/commit reworks).
Add Comment