Home Explore Blog CI



git

4th chunk of `Documentation/git-branch.adoc`
cc164b7e6e92e5b790641a97cf0682a821a86482bad1ac7f0000000100000dcf

	upstream when the new branch is checked out.
+
The exact upstream branch is chosen depending on the optional argument:
`-t`, `--track`, or `--track=direct` means to use the start-point branch
itself as the upstream; `--track=inherit` means to copy the upstream
configuration of the start-point branch.
+
The `branch.autoSetupMerge` configuration variable specifies how `git switch`,
`git checkout` and `git branch` should behave when neither `--track` nor
`--no-track` are specified:
+
The default option, `true`, behaves as though `--track=direct`
were given whenever the start-point is a remote-tracking branch.
`false` behaves as if `--no-track` were given. `always` behaves as though
`--track=direct` were given. `inherit` behaves as though `--track=inherit`
were given. `simple` behaves as though `--track=direct` were given only when
the _<start-point>_ is a remote-tracking branch and the new branch has the same
name as the remote branch.
+
See linkgit:git-pull[1] and linkgit:git-config[1] for additional discussion on
how the `branch.<name>.remote` and `branch.<name>.merge` options are used.

`--no-track`::
	Do not set up "upstream" configuration, even if the
	`branch.autoSetupMerge` configuration variable is set.

`--recurse-submodules`::
	THIS OPTION IS EXPERIMENTAL! Cause the current command to
	recurse into submodules if `submodule.propagateBranches` is
	enabled. See `submodule.propagateBranches` in
	linkgit:git-config[1]. Currently, only branch creation is
	supported.
+
When used in branch creation, a new branch _<branch-name>_ will be created
in the superproject and all of the submodules in the superproject's
_<start-point>_. In submodules, the branch will point to the submodule
commit in the superproject's _<start-point>_ but the branch's tracking
information will be set up based on the submodule's branches and remotes
e.g. `git branch --recurse-submodules topic origin/main` will create the
submodule branch "topic" that points to the submodule commit in the
superproject's "origin/main", but tracks the submodule's "origin/main".

`--set-upstream`::
	As this option had confusing syntax, it is no longer supported.
	Please use `--track` or `--set-upstream-to` instead.

`-u <upstream>`::
`--set-upstream-to=<upstream>`::
	Set up _<branch-name>_'s tracking information so _<upstream>_ is
	considered _<branch-name>_'s upstream branch. If no _<branch-name>_
	is specified, then it defaults to the current branch.

`--unset-upstream`::
	Remove the upstream information for _<branch-name>_. If no branch
	is specified it defaults to the current branch.

`--edit-description`::
	Open an editor and edit the text to explain what the branch is
	for, to be used by various other commands (e.g. `format-patch`,
	`request-pull`, and `merge` (if enabled)). Multi-line explanations
	may be used.

`--contains [<commit>]`::
	Only list branches which contain _<commit>_ (`HEAD`
	if not specified). Implies `--list`.

`--no-contains [<commit>]`::
	Only list branches which don't contain _<commit>_
	(`HEAD` if not specified). Implies `--list`.

`--merged [<commit>]`::
	Only list branches whose tips are reachable from
	_<commit>_ (`HEAD` if not specified). Implies `--list`.

`--no-merged [<commit>]`::
	Only list branches whose tips are not reachable from
	_<commit>_ (`HEAD` if not specified). Implies `--list`.

`--points-at <object>`::
	Only list branches of _<object>_.

`--format <format>`::
	A string that interpolates `%(fieldname)` from a branch ref being shown
	and the object it points at.  _<format>_

Title: Git Branch Command Options for Tracking and Filtering
Summary
The git branch command offers various options for tracking and filtering branches, including setting up upstream configurations, recursing into submodules, and listing branches based on specific conditions such as containing or reaching certain commits, with flags like --track, --recurse-submodules, --contains, and --format.