Follow

Do you use `git checkout` still? Stop.

Meet `git switch` and `git restore`.

I've totally switched (:blobcatfacepalm:) to `git switch`. If you want to incorporate it in your everyday routine, consider remembering useful `-c` and `-d` options.

git-scm.com/docs/git-switch

git-scm.com/docs/git-restore

@lig I know about the new commands, but using checkout in its various forms is too ingrained into my memory at this point. :D

@nicd It's good to try something new from time to time:)

@lig I’ve tried restore but I like reset better. Maybe that’s because it was meant to replace checkout instead, but I lost some changes I meant to keep because of it.

@IslandUsurper well, restore isn't a replacement for reset, indeed.
"reset" is here to stay for a while.

@lig git switch doesn’t seem to allow switching to a commit hash or tag name, only a branch. In that respect, git checkout is still useful.

@Crocmagnon Have you noticed the `-d` option, I've mentioned?

@lig No I haven’t! Thanks for pointing that out again 🙏🏻 I focused on -c.

@lig I don't really see why git switch is better than checkout as they do the same. Despite that, git restore is awesome and its syntax is much better than git checkout HEAD -- files.

@yyp well, you've actually got three point of switch. It's not checkout and not restore. If you're incorporating restore in your workflow, it seems like a good idea to use switch which completely distinguishes two behaviors for you. Also, 'switch -c' after hitting non-existing branch feels really natural to me.

@lig I'll try git switch and see how it goes

Sign in to participate in the conversation
Fosstodon

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.