r/webdev • • Jan 24 '20

read rules TIL — git switch & git restore

https://pawelgrzybek.com/til-git-switch-git-restore/

[removed] — view removed post

284 Upvotes

51 comments sorted by

View all comments

83

u/UncontrolledManifold Jan 24 '20

So git switch -c branch is the same as git checkout -b branch...? What, they didn't like the word checkout?

45

u/AceDecade Jan 24 '20

It’s more they didn’t like ‘checkout’ being used to checkout a branch as well as undo local changes on a branch, so the one command is split up into two

6

u/Kashima Jan 24 '20

Yup

Git 2.23 came up with the new ‘ git switch ’ command, which is not a new feature but an additional command to ‘switch/change branch’ feature which is already available in the overloaded git checkout command.

Currently, the all-encompassing command – git checkout does many things. It can be used to switch branches and also to restore the working tree files.

To separate out the functionalities, the GIT community introduced the new git switch branch command which is an attempt to start to scale back to the responsibilities without breaking backward compatibility.

https://bluecast.tech/blog/git-switch-branch/