cm0002@mander.xyz to Programmer Humor@programming.dev · 2 months agoWhen you have to checkout the master branchlemmy.worldimagemessage-square17linkfedilinkarrow-up1413arrow-down15
arrow-up1408arrow-down1imageWhen you have to checkout the master branchlemmy.worldcm0002@mander.xyz to Programmer Humor@programming.dev · 2 months agomessage-square17linkfedilink
minus-squareEager Eagle@lemmy.worldlinkfedilinkEnglisharrow-up37·2 months agoit 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.
minus-squareScrollone@feddit.itlinkfedilinkarrow-up1·2 months agoI agree, I wonder why they decided to design it that way in the first place.
minus-squarepaperplane@lemmy.worldlinkfedilinkarrow-up1·1 month agoIn 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
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 switchand the unsafe withgit restore.I agree, I wonder why they decided to design it that way in the first place.
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