Home Explore Blog CI



git

2nd chunk of `Documentation/git-checkout.adoc`
17cef17cda9b63be09c775a86a5c6afd414ce00f0df3cdcb0000000100000fa1
	modifications.
+
When the _<commit>_ argument is a branch name, the `--detach` option can
be used to detach `HEAD` at the tip of the branch (`git checkout
<branch>` would check out that branch without detaching `HEAD`).
+
Omitting _<branch>_ detaches `HEAD` at the tip of the current branch.

`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>...`::
`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul]`::

	Overwrite the contents of the files that match the pathspec.
	When the _<tree-ish>_ (most often a commit) is not given,
	overwrite working tree with the contents in the index.
	When the _<tree-ish>_ is given, overwrite both the index and
	the working tree with the contents at the _<tree-ish>_.
+
The index may contain unmerged entries because of a previous failed merge.
By default, if you try to check out such an entry from the index, the
checkout operation will fail and nothing will be checked out.
Using `-f` will ignore these unmerged entries.  The contents from a
specific side of the merge can be checked out of the index by
using `--ours` or `--theirs`.  With `-m`, changes made to the working tree
file can be discarded to re-create the original conflicted merge result.

`git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>...]`::
	This is similar to the previous mode, but lets you use the
	interactive interface to show the "diff" output and choose which
	hunks to use in the result.  See below for the description of
	`--patch` option.

OPTIONS
-------
`-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`.

`-f`::
`--force`::
	When switching branches, proceed even if the index or the
	working tree differs from `HEAD`, and even if there are untracked
	files in the way.  This is used to throw away local changes and
	any untracked files or directories that are in the way.
+
When checking out paths from the index, do not fail upon unmerged
entries; instead, unmerged entries are ignored.

`--ours`::
`--theirs`::
	When checking out paths from the index, check out stage #2
	(`ours`) or #3 (`theirs`) for unmerged paths.
+
Note that during `git rebase` and `git pull --rebase`, `ours` and
`theirs` may appear swapped; `--ours` gives the version from the
branch the changes are rebased onto, while `--theirs` gives the
version from the branch that holds your work that is being rebased.
+
This is because `rebase` is used in a workflow that treats the
history at the remote as the shared canonical one, and treats the
work done on the branch you are rebasing as the third-party work to
be integrated, and you are temporarily assuming the role of the
keeper of the canonical history during the rebase.  As the keeper of
the canonical history, you need to view the history from the remote
as `ours` (i.e. "our shared canonical history"), while what you did
on your side branch as `theirs` (i.e. "one contributor's work on top
of it").

`-b <new-branch>`::
	Create a new branch named _<new-branch>_, start it at
	_<start-point>_, and check the resulting branch out;
	see linkgit:git-branch[1] for details.

`-B <new-branch>`::
	Creates the branch _<new-branch>_, start it at _<start-point>_;
	if it already exists, then reset it to _<start-point>_. And then
	check the resulting branch out.  This is equivalent to running
	`git branch` with `-f` followed by `git checkout` of that branch;
	see linkgit:git-branch[1] for details.

`-t`::
`--track[=(direct|inherit)]`::
	When creating a new branch, set up "upstream" configuration. See
	`--track` in linkgit:git-branch[1] for details.
+
If no `-b` option is given, the name of the new branch will be
derived from the remote-tracking branch, by looking at

Title: Git Checkout Options and Parameters
Summary
The git checkout command has various options and parameters that allow users to customize its behavior, including switching branches, creating new branches, and overwriting files, as well as options for handling conflicts, progress reporting, and quiet mode.