Yeah learned this the hard way.

  • Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    94
    ·
    22 days ago

    I’ve had juniors who didn’t believe this, so just to say it: If you know what you’re doing, practically any Git problem is recoverable.

    The one major exception is if you delete your local changes before committing them.

    • sucoiri@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      21 days ago

      Fun fact! If you added a file but never committed it you can still recover it with git fsck --lost-and-found. The changes were still added to the git object store, and by grepping through the dangling blobs you can find the object containing the changes you care about.

    • BootLoop@sh.itjust.works
      link
      fedilink
      arrow-up
      3
      ·
      22 days ago

      Does deleting the repo off disk and redownloading from remote considered recovering? If so I’m a git expert.

          • toynbee@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            21 days ago

            I mostly only use git at work and I guess I’ve never had the same work machine long enough to worry about this. It helps that each of our repos is fairly small. At least the ones I touch.