git checkout [branch, file, tag or commit] [pathspec...]

Switch branches or restore working tree files


branch, file, tag or commitBranch, file, tag or commit to switch to
pathspecLimits the paths affected by the operation


-q, --quietQuiet, suppress feedback messages
--progressProgress 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
--no-progressDisable progress status reporting
-f, --forceWhen switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes
-2, --oursWhen checking out paths from the index, check out stage #2 (ours) for unmerged paths
-3, --theirsWhen checking out paths from the index, check out stage #3 (theirs) for unmerged paths
-b <New Branch>Create a new branch named <new_branch> and start it at <start_point>; see git-branch[1] for details
-B <New Branch>Creates the branch <new_branch> and start it at <start_point>; if it already exists, then reset it to <start_point>. This is equivalent to running 'git branch' with '-f'; see git-branch[1] for details
-t, --trackWhen creating a new branch, set up 'upstream' configuration
--no-trackDo not set up 'upstream' configuration, even if the branch.autoSetupMerge configuration variable is true
--guessIf <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to $ git checkout -b <branch> --track <remote>/<branch>
--no-guessDisable --guess
-lCreate the new branch’s reflog; see git-branch[1] for details
-d, --detachRather than checking out a branch to work on it, check out a commit for inspection and discardable experiments. This is the default behavior of git checkout <commit> when <commit> is not a branch name
--orphan <New Branch>Create a new orphan branch, named <new_branch>, started from <start_point> and switch to it
--ignore-skip-worktree-bitsIn sparse checkout mode, git checkout -- <paths> would update only entries matched by <paths> and sparse patterns in $GIT_DIR/info/sparse-checkout. This option ignores the sparse patterns and adds back any files in <paths>
-m, --mergeWhen switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context
--conflict [arg]The same as --merge option above, but changes the way the conflicting hunks are presented, overriding the merge.conflictStyle configuration variable. Possible values are 'merge' (default) and 'diff3' (in addition to what is shown by 'merge' style, shows the original contents)
-p, --patchInteractively select hunks in the difference between the <tree-ish> (or the index, if unspecified) and the working tree
--ignore-other-worktreesGit checkout 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
--overwrite-ignoreSilently overwrite ignored files when switching branches. This is the default behavior
--no-overwrite-ignoreUse --no-overwrite-ignore to abort the operation when the new branch contains ignored files
--recurse-submodulesUsing --recurse-submodules will update the content of all active submodules according to the commit recorded in the superproject. If local modifications in a submodule would be overwritten the checkout will fail unless -f is used. If nothing (or --no-recurse-submodules) is used, submodules working trees will not be updated. Just like git-submodule[1], this will detach HEAD of the submodule
--no-recurse-submodulesSubmodules working trees will not be updated
--overlayIn the default overlay mode, git checkout never removes files from the index or the working tree
--no-overlayWhen specifying --no-overlay, files that appear in the index and working tree, but not in <tree-ish> are removed, to make them match <tree-ish> exactly
--pathspec-from-file <file>Pathspec is passed in <file> instead of commandline args
--pathspec-file-nulOnly meaningful with --pathspec-from-file