(default), `diff3`, and `zdiff3`.
`-q`::
`--quiet`::
Quiet, suppress feedback messages.
`--progress`::
`--no-progress`::
Progress status is reported on the standard error stream
by default when it is attached to a terminal, unless `--quiet`
is specified. This flag enables progress reporting even if not
attached to a terminal, regardless of `--quiet`.
`-t`::
`--track[ (direct|inherit)]`::
When creating a new branch, set up "upstream" configuration.
`-c` is implied. See `--track` in linkgit:git-branch[1] for
details.
+
If no `-c` option is given, the name of the new branch will be derived
from the remote-tracking branch, by looking at the local part of the
refspec configured for the corresponding remote, and then stripping
the initial part up to the "*". This would tell us to use `hack` as
the local branch when branching off of `origin/hack` (or
`remotes/origin/hack`, or even `refs/remotes/origin/hack`). If the
given name has no slash, or the above guessing results in an empty
name, the guessing is aborted. You can explicitly give a name with
`-c` in such a case.
`--no-track`::
Do not set up "upstream" configuration, even if the
`branch.autoSetupMerge` configuration variable is true.
`--orphan <new-branch>`::
Create a new unborn branch, named _<new-branch>_. All
tracked files are removed.
`--ignore-other-worktrees`::
`git switch` refuses when the wanted ref is already
checked out by another worktree. This option makes it check
the ref out anyway. In other words, the ref can be held by
more than one worktree.
`--recurse-submodules`::
`--no-recurse-submodules`::
Using `--recurse-submodules` will update the content of all
active submodules according to the commit recorded in the
superproject. If nothing (or `--no-recurse-submodules`) is
used, submodules working trees will not be updated. Just
like linkgit:git-submodule[1], this will detach `HEAD` of the
submodules.
EXAMPLES
--------
The following command switches to the "master" branch:
------------
$ git switch master
------------
After working in the wrong branch, switching to the correct branch
would be done using:
------------
$ git switch mytopic
------------
However, your "wrong" branch and correct "mytopic" branch may differ
in files that you have modified locally, in which case the above
switch would fail like this:
------------
$ git switch mytopic
error: You have local changes to 'frotz'; not switching branches.
------------
You can give the `-m` flag to the command, which would try a three-way
merge:
------------
$ git switch -m mytopic
Auto-merging frotz
------------
After this three-way merge, the local modifications are _not_
registered in your index file, so `git diff` would show you what
changes you made since the tip of the new branch.
To switch back to the previous branch before we switched to mytopic
(i.e. "master" branch):
------------
$ git switch -
------------
You can grow a new branch from any commit. For example, switch to
"`HEAD~3`" and create branch "`fixup`":
------------
$ git switch -c fixup HEAD~3
Switched to a new branch 'fixup'
------------
If you want to start a new branch from a remote branch of the same
name:
------------
$ git switch new-topic
Branch `new-topic` set up to track remote branch `new-topic` from `origin`
Switched to a new branch `new-topic`
------------
To check out commit `HEAD~3` for temporary inspection or experiment
without creating a new branch:
------------
$ git switch --detach HEAD~3
HEAD is now at 9fc9555312 Merge branch 'cc/shared-index-permbits'
------------
If it turns out whatever you have done is worth keeping, you can
always create a new name for it (without switching away):
------------
$ git switch -c good-surprises
------------
CONFIGURATION
-------------
include::includes/cmd-config-section-all.adoc[]
include::config/checkout.adoc[]
SEE ALSO
--------
linkgit:git-checkout[1],
linkgit:git-branch[1]
GIT
---
Part of the linkgit:git[1] suite