Home Explore Blog CI



git

4th chunk of `Documentation/git-checkout.adoc`
7a91c8f36ef0403a6af6f147a1773b1e9a54d3c4e83f4fa70000000100000fa4
 be the root of a new
	history totally disconnected from all the other branches and
	commits.
+
The index and the working tree are adjusted as if you had previously run
`git checkout <start-point>`.  This allows you to start a new history
that records a set of paths similar to _<start-point>_ by easily running
`git commit -a` to make the root commit.
+
This can be useful when you want to publish the tree from a commit
without exposing its full history. You might want to do this to publish
an open source branch of a project whose current tree is "clean", but
whose full history contains proprietary or otherwise encumbered bits of
code.
+
If you want to start a disconnected history that records a set of paths
that is totally different from the one of _<start-point>_, then you should
clear the index and the working tree right after creating the orphan
branch by running `git rm -rf .` from the top level of the working tree.
Afterwards you will be ready to prepare your new files, repopulating the
working tree, by copying them from elsewhere, extracting a tarball, etc.

`--ignore-skip-worktree-bits`::
	In sparse checkout mode, `git checkout -- <path>...` 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 `<path>...`.

`-m`::
`--merge`::
	When 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.
	However, with this option, a three-way merge between the current
	branch, your working tree contents, and the new branch
	is done, and you will be on the new branch.
+
When a merge conflict happens, the index entries for conflicting
paths are left unmerged, and you need to resolve the conflicts
and mark the resolved paths with `git add` (or `git rm` if the merge
should result in deletion of the path).
+
When checking out paths from the index, this option lets you recreate
the conflicted merge in the specified paths.  This option cannot be
used when checking out paths from a tree-ish.
+
When switching branches with `--merge`, staged changes may be lost.

`--conflict=<style>`::
	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), `diff3`, and `zdiff3`.

`-p`::
`--patch`::
	Interactively select hunks in the difference between the
	_<tree-ish>_ (or the index, if unspecified) and the working
	tree.  The chosen hunks are then applied in reverse to the
	working tree (and if a _<tree-ish>_ was specified, the index).
+
This means that you can use `git checkout -p` to selectively discard
edits from your current working tree. See the "Interactive Mode"
section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
+
Note that this option uses the no overlay mode by default (see also
`--overlay`), and currently doesn't support overlay mode.

`--ignore-other-worktrees`::
	`git checkout` refuses when the wanted branch is already checked
	out or otherwise in use by another worktree. This option makes
	it check the branch out anyway. In other words, the branch can
	be in use by more than one worktree.

`--overwrite-ignore`::
`--no-overwrite-ignore`::
	Silently overwrite ignored files when switching branches. This
	is the default behavior. Use `--no-overwrite-ignore` to abort
	the operation when the new branch contains ignored files.

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

Title: Git Checkout Options for Managing Branches and Files
Summary
The git checkout command has various options for managing branches, files, and submodules, including creating orphan branches, resolving merge conflicts, and handling ignored files, as well as options for interactive mode, patch mode, and recursive submodule updates.