Tl dr: When using checkout with -force, you can switch branches while in the middle of a merge. force has also been renamed to -discard-changes, with -force being kept as an alias. Switching using -force now fails if there are unmerged entries, rather than ignoring them.The source tree for restoring is now given by the -s (or -source) option, rather than being an inline argument. -detach (or -d) is now always required when switching to a detached head, where it was previously optional for commits but required for branches.They also have long option variants ( -create/ -force-create), whereas previously they only had the single letter option versions. The -b/ -B options for creating a new branch before switching are renamed to -c/ -C.N/A (use git switch then git switch -orphan )Īs shown in this comparison, some prior usages can be converted to the new commands by replacing the old command name ( checkout) to the new one ( switch, restore), whereas others require additional adjustment. From reading through the documentation, I think this should be a fairly complete comparison: I have not found a full comparison of the commands anywhere. Note that as of December 2021, the new commands are still listed as experimental ( switch, restore): Old "git checkout" command is still here and will be until all (or mostįrom this, it's clear that the new commands were introduced to reduce confusion by having two focused commands, rather than one multi-purpose command. To remedy that, theĬommand will be split into two new ones: switch and restore. Users (and it even bites old timers sometimes). "git checkout" doing too many things is a source of confusion for many The commit that added the switch command explains the rationale for the new commands in its commit message: Git-checkout - Switch branches or restore working tree files This dual purpose of checkout can be seen in its summary description in the documentation: In other words, checkout does two different things, and this release split each of those different things into its own focused command. "checking out paths out of the index and/or a tree-ish to work on advancing the current history"."checking out a branch to work on advancing its history".Detailed explanationĪs you noted in the 2.23.0 release notes section you quoted, the switch and restore commands were introduced to split the checkout command into two separate pieces: In particular, unlike checkout it cannot restore working tree files - that is instead done using the restore command that was introduced alongside switch. The switch command indeed does the same thing as checkout, but only for those usages that switch branches.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |