Home Explore Blog CI



git

2nd chunk of `Documentation/git-branch.adoc`
d7c3f2d0fa8527e7d873eb043ff9013bc3298dad02e47a9b0000000100000fa1

`branch.autoSetupMerge` configuration flag. That setting can be
overridden by using the `--track` and `--no-track` options, and
changed later using `git branch --set-upstream-to`.

With a `-m` or `-M` option, _<old-branch>_ will be renamed to _<new-branch>_.
If _<old-branch>_ had a corresponding reflog, it is renamed to match
_<new-branch>_, and a reflog entry is created to remember the branch
renaming. If _<new-branch>_ exists, `-M` must be used to force the rename
to happen.

The `-c` and `-C` options have the exact same semantics as `-m` and
`-M`, except instead of the branch being renamed, it will be copied to a
new name, along with its config and reflog.

With a `-d` or `-D` option, _<branch-name>_ will be deleted.  You may
specify more than one branch for deletion.  If the branch currently
has a reflog then the reflog will also be deleted.

Use `-r` together with `-d` to delete remote-tracking branches. Note, that it
only makes sense to delete remote-tracking branches if they no longer exist
in the remote repository or if `git fetch` was configured not to fetch
them again. See also the `prune` subcommand of linkgit:git-remote[1] for a
way to clean up all obsolete remote-tracking branches.


OPTIONS
-------
`-d`::
`--delete`::
	Delete a branch. The branch must be fully merged in its
	upstream branch, or in `HEAD` if no upstream was set with
	`--track` or `--set-upstream-to`.

`-D`::
	Shortcut for `--delete --force`.

`--create-reflog`::
	Create the branch's reflog.  This activates recording of
	all changes made to the branch ref, enabling use of date
	based sha1 expressions such as `<branch-name>@{yesterday}`.
	Note that in non-bare repositories, reflogs are usually
	enabled by default by the `core.logAllRefUpdates` config option.
	The negated form `--no-create-reflog` only overrides an earlier
	`--create-reflog`, but currently does not negate the setting of
	`core.logAllRefUpdates`.

`-f`::
`--force`::
	Reset _<branch-name>_ to _<start-point>_, even if _<branch-name>_ exists
	already. Without `-f`, `git branch` refuses to change an existing branch.
	In combination with `-d` (or `--delete`), allow deleting the
	branch irrespective of its merged status, or whether it even
	points to a valid commit. In combination with
	`-m` (or `--move`), allow renaming the branch even if the new
	branch name already exists, the same applies for `-c` (or `--copy`).
+
Note that `git branch -f <branch-name> [<start-point>]`, even with `-f`,
refuses to change an existing branch _<branch-name>_ that is checked out
in another worktree linked to the same repository.

`-m`::
`--move`::
	Move/rename a branch, together with its config and reflog.

`-M`::
	Shortcut for `--move --force`.

`-c`::
`--copy`::
	Copy a branch, together with its config and reflog.

`-C`::
	Shortcut for `--copy --force`.

`--color[=<when>]`::
	Color branches to highlight current, local, and
	remote-tracking branches.
	The value must be `always` (the default), `never`, or `auto`.

`--no-color`::
	Turn off branch colors, even when the configuration file gives the
	default to color output.
	Same as `--color=never`.

`-i`::
`--ignore-case`::
	Sorting and filtering branches are case insensitive.

`--omit-empty`::
	Do not print a newline after formatted refs where the format expands
	to the empty string.

`--column[=<options>]`::
`--no-column`::
	Display branch listing in columns. See configuration variable
	`column.branch` for option syntax. `--column` and `--no-column`
	without options are equivalent to `always` and `never` respectively.
+
This option is only applicable in non-verbose mode.

`--sort=<key>`::
	Sort based on _<key>_. Prefix `-` to sort in descending
	order of the value. You may use the `--sort=<key>` option
	multiple times, in which case the last key becomes the primary
	key. The keys supported are the same as those in linkgit:git-for-each-ref[1].
	Sort order defaults to the value configured for the
	`branch.sort` variable if it exists, or to sorting based on the

Title: Git Branch Options and Commands
Summary
The git branch command offers various options for managing branches, including renaming, copying, and deleting branches, as well as configuring tracking and merge settings, with flags such as -d, -m, -c, and --set-upstream-to, and also provides options for customizing the display of branch listings, such as --color, --column, and --sort.