this post was submitted on 09 Dec 2025
464 points (98.7% liked)

Programmer Humor

28365 readers
1054 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] eager_eagle@lemmy.world 46 points 1 month ago (2 children)

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.

[–] tux0r@feddit.org 14 points 1 month ago (2 children)

Ah, I love coherent software.

[–] sik0fewl@lemmy.ca 13 points 1 month ago (1 children)

Switch and restore came later because checkout was problematic.

[–] nightlily@leminal.space 3 points 1 month ago* (last edited 1 month ago) (1 children)

Has someone made a „Checkout considered harmful“ blog post yet or do we not do that anymore?

[–] anomnom@sh.itjust.works 1 points 1 month ago

E we used to always stash before checkouts to try and find things in a branch

Just alias stuff like that, make it coherent.

[–] Scrollone@feddit.it 1 points 1 month ago (1 children)

I agree, I wonder why they decided to design it that way in the first place.

[–] paperplane@lemmy.world 1 points 3 weeks 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