cm0002@mander.xyz to Programmer Humor@programming.dev · 26 days agoWhen you have to checkout the master branchlemmy.worldimagemessage-square10linkfedilinkarrow-up14arrow-down10
arrow-up14arrow-down1imageWhen you have to checkout the master branchlemmy.worldcm0002@mander.xyz to Programmer Humor@programming.dev · 26 days agomessage-square10linkfedilink
minus-squareEager Eagle@lemmy.worldlinkfedilinkEnglisharrow-up0·26 days 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-up0·25 days agoI agree, I wonder why they decided to design it that way in the first place.
minus-squarepaperplane@lemmy.worldlinkfedilinkarrow-up1·15 days 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