Git - Documentation of git-checkout (2023)

-Q
--still

Quiet, suppress feedback.

--Progress
--no progress

Progress status is reported in the standard error stream by default when connected to a terminal, unless--stillSpecified. This flag allows progress reporting even when not connected to a terminal, regardless of--still.

-F
--Strength

Proceed when switching branches even if index or working tree is differentKOPF, and even if untracked files are in the path. This is used to discard local changes and any untracked files or directories that are in the path.

When checking out index paths, don't fail unmerged entries; instead, unmerged entries are ignored.

--our
-- that

When checking index paths, check level 2 (our) Or 3 (whether) for unmerged paths.

Note that duringGit-RebaseNameEgit pull --rebase,ourEwhethermay appear inverted;--ourSpecifies the branch version on which changes are rebased while-- thatspecifies the version of the branch that contains your work to be rebased.

It is becausefuchsused in a workflow that treats the history on the remote side as the shared canonical history and the work done on the branch you are rebasing as the third-party work to be integrated and you temporarily assume the canonical history manager role in the Remake. As a canonical history keeper, you need to view remote control historyour(i.e. "our shared canonical history"), while what you did in your side branch aswhether(i.e. "the work of a contributor at the top").

-b <new branch>

Create a new branch with the name<new-branch>and start it on<starting point>; vergit-branch[1]for details.

-B <new branch>

Create the branch<new-branch>and start it on<starting point>;if it already exists, reset it to<starting point>. This is equivalent to running git branch with -f; to seegit-branch[1]for details.

-T
--track[=(direct|inherit)]

Set the "upstream" setting when creating a new branch. See "--track" ingit-branch[1]for details.

If not-BIf the option is specified, the name of the new branch is derived from the remote tracking branch by looking at the local part of the refspec configured for the corresponding remote and then stripping the leading part down to the use of "*"cutas a local branch at the junction ofOrigin/Hack(orRemote Controls/Origin/Hack, or alsorefs/remotes/origin/hack). If the first name does not have a slash or the above guess results in an empty name, the guess is cancelled. With you can explicitly assign a name-Bin that case.

--no trace

Do not configure an "upstream" configuration, even if thebranch.autoSetupMergeThe configuration variable is true.

--saying
- no idea

Se<Zweig>not found, but there is a trace branch on exactly one remote (name it<remote control>) with the corresponding name as equivalent

$ git checkout -b <Zweig> --track <Remote>/<Zweig>

If the branch exists on multiple remotes and one of them is named bycheckout.defaultRemotoconfiguration variable, we'll use this for disambiguation purposes, even though the<Zweig>it is not the same on all remotes. Put for examplecheckout.defaultRemote=UrsprungAlways check the remote branches from there when<Zweig>is ambiguous, but exists in theOriginRemote Control. See toocheckout.defaultRemotoEmgit-config[1].

--sayingis the default behavior. To use- no ideato disable it.

The default behavior can be set viacheck-out.palpiteconfiguration variable.

-eu

Create the new branch's reflog; to seegit-branch[1]for details.

-D
-- disassociate

Instead of checking out a branch to work on it, check out a commit to inspect it and discard experiments. This is the default behavior ofgit checkout <commit>Se<compromise>it is not a branch name. See HEAD REMOVAL section below for details.

--orphan <new-branch>

create a neworphanbranch, named<new-branch>, started in<starting point>and switch to it. The first commit made on this new branch will have no parent, and will be the root of a new history completely separate from all other branches and commits.

The index and working tree are adjusted as if you had previously rungit checkout <start point>. This allows you to start a new journey that will record a series of similar paths.<starting point>walking lightlygit commit -ato do the root commit.

This can be useful if you want to publish a commit tree without exposing its full history. You might want to do this to release an open source branch of a project whose current tree is "clean" but whose full history contains proprietary or otherwise overloaded bits of code.

If you want to start a separate history that records a completely different set of paths than that of<starting point>, you must delete the index and working tree right after creating the orphaned branch by running itgit rm -rf .from the top level of the working tree. After that, you're ready to prepare your new files, repopulate the working tree, copy them from elsewhere, extract a tarball, etc.

--ignore-skip-worktree-bits

Im Sparse-Checkout-Modusgit checkout -- <paths>would only update the entries that match<paths>and sparse patterns$GIT_DIR/info/sparse-checkout. This option ignores sparse patterns and adds all files back<paths>.

-M
--merge

When switching branches, if you have made local changes to one or more files that differ between the current branch and the branch you are switching to, the command refuses to switch branches to preserve your changes in context. With this option, however, a three-way merge between the current branch, the contents of your working tree, and the new branch is complete and you are on the new branch.

If a merge conflict occurs, the index entries for conflicting paths will not be merged and you must resolve the conflicts and mark the resolved paths withadd git(orgit rmif the merge results in the path being excluded).

When checking out index paths, this option allows you to recreate the conflicting merge on the specified paths.

When switching branches with--merge, staggered changes may be lost.

--conflict=<Yet>

The same as--mergeOption above, but changes how conflicting blocks are presented and replaces themmerge.conflictStyleconfiguration variable. Possible values ​​are merge (default), diff3, and zdiff3.

-P
- Correction

Select chunks interactively on the difference between the<tree>(or the index if not specified) and the working tree. The selected snippets are then applied in reverse in the working tree (and if a<tree>specified, the index).

This means you can usegit checkout -pto selectively discard changes from your current working tree. See the Interactive Mode section ofgit-add[1]to learn to use it- CorrectionWay.

Note that this option defaults to non-overlapping mode (see also- Overlay) and currently does not support overlay mode.

--ignore-other-work-trees

git check-outdenied if the desired reference has already been taken from another working tree. With this option, the refout is still checked. In other words, the reference can be maintained by more than one working tree.

--overwrite-ignore
--no-overwrite-ignore

Silently replace skipped files when switching branches. This is the default behavior. To use--no-overwrite-ignoreto abort if the new branch contains skipped files.

--recurse-submodules
--no-recurse-submodules

To use--recurse-submodulesupdates the content of all active submodules according to the commit recorded in the superproject. If local changes in a submodule are overwritten, checkout will fail-Fit is used. If nothing (or--no-recurse-submodules) is used, submodules working trees are not updatedgit-submodule[1], this will solveKOPFdes Submoduls.

- Overlay
--no overlapping

In default overlay modegit check-outnever removes files from the index or framework. when specified--no overlapping, files that appear in the index and working tree, but not in the<tree>removed to make them match<tree>Exactly.

--pathspec-from-file=<Data>

Pathspec is passed<file>instead of command line arguments. if<file>it's needed-then standard input is used. Path specification elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variablecore.quotePath(vergit-config[1]). See too--pathspec-file-nullglobal--literal-pathspecs.

--pathspec-file-null

Useful only with--pathspec-from-file. Pathspec elements are separated by NUL characters, and all other characters are interpreted literally (including newlines and double quotes).

<Zweig>

Skip to Checkout; if it refers to a branch (that is, a name which, when preceded by "refs/heads/" is a valid reference), then that branch is checked. Otherwise, if it refers to a valid commit, yourKOPFbecomes "disconnected" and you are no longer on a branch (see below for details).

You can use the...@{-N}Syntax for referring to the nth last branch/commit checked out with the "git checkout" operation. You can also specify-What's up with that@{-1}.

As a special case, you can useA...Bas a thermal base abbreviation ofAEBif there is exactly one merge base. You can omit at most one of them.AEB, in which case the default isKOPF.

<new-branch>

Name of the new branch.

<starting point>

The name of a commit on which to start the new branch; to seegit-branch[1]for details. The default isKOPF.

As a special case, you can use"A...B"as a thermal base abbreviation ofAEBif there is exactly one merge base. You can omit at most one of them.AEB, in which case the default isKOPF.

<tree>

Tree to check (if paths are specified). If not specified, the index is used.

As a special case, you can use"A...B"as a thermal base abbreviation ofAEBif there is exactly one merge base. You can omit at most one of them.AEB, in which case the default isKOPF.

--

Do not interpret additional arguments as options.

<path specification>…​

Restricts the paths affected by the operation.

For more details seepathspecProhibitedgitglossary[7].

Top Articles
Latest Posts
Article information

Author: Trent Wehner

Last Updated: 03/18/2023

Views: 6380

Rating: 4.6 / 5 (56 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Trent Wehner

Birthday: 1993-03-14

Address: 872 Kevin Squares, New Codyville, AK 01785-0416

Phone: +18698800304764

Job: Senior Farming Developer

Hobby: Paintball, Calligraphy, Hunting, Flying disc, Lapidary, Rafting, Inline skating

Introduction: My name is Trent Wehner, I am a talented, brainy, zealous, light, funny, gleaming, attractive person who loves writing and wants to share my knowledge and understanding with you.