this post was submitted on 14 Dec 2023
68 points (93.6% liked)

Programming

17333 readers
361 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 10 months ago

2019, so 4-5 years ago so not that recent but not ancient either. But unfortunately tutorials have not been updated.

I would say that the biggest benefit of git switch is that you can't switch to a detached state without using a flag (--detached or -d). If you do git co $tag or git co $sha-1 you may get at one point the error “you are in a detached state” which is ununderstable for begginers. To get the same error with git switch you must explicitely use git switch --detached $tag/$sha-1 which makes it much easier to understand and remember that you are going to do something unusual.

More generally it's harder to misuse git switch/git restore. And it's easier to explain them since the only do one thing (unlike git checkout which is a mess !).

So if it's only for you git checkout is fine, but I would still advice to use git switch and git restore so you will have an easier time to teach/help begginers.