• Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    26 days ago

    it has always bothered me that checkout is overloaded: it can switch branches or discard pending changes in an unrecoverable way.

    so, PSA, you can replicate the safe part of checkout with git switch and the unsafe with git restore.

      • paperplane@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        15 days ago

        In both cases, checkout updates your working tree (by checking out either all or just some files from a commit), just when you’re switching branches it moves your HEAD pointer too