logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-branch.1 (25707B)


  1. '\" t
  2. .\" Title: git-branch
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-BRANCH" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-branch \- List, create, or delete branches
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fIgit branch\fR [\-\-color[=<when>] | \-\-no\-color] [\-\-show\-current]
  36. [\-v [\-\-abbrev=<n> | \-\-no\-abbrev]]
  37. [\-\-column[=<options>] | \-\-no\-column] [\-\-sort=<key>]
  38. [\-\-merged [<commit>]] [\-\-no\-merged [<commit>]]
  39. [\-\-contains [<commit>]] [\-\-no\-contains [<commit>]]
  40. [\-\-points\-at <object>] [\-\-format=<format>]
  41. [(\-r | \-\-remotes) | (\-a | \-\-all)]
  42. [\-\-list] [<pattern>\&...\:]
  43. \fIgit branch\fR [\-\-track[=(direct|inherit)] | \-\-no\-track] [\-f]
  44. [\-\-recurse\-submodules] <branchname> [<start\-point>]
  45. \fIgit branch\fR (\-\-set\-upstream\-to=<upstream> | \-u <upstream>) [<branchname>]
  46. \fIgit branch\fR \-\-unset\-upstream [<branchname>]
  47. \fIgit branch\fR (\-m | \-M) [<oldbranch>] <newbranch>
  48. \fIgit branch\fR (\-c | \-C) [<oldbranch>] <newbranch>
  49. \fIgit branch\fR (\-d | \-D) [\-r] <branchname>\&...\:
  50. \fIgit branch\fR \-\-edit\-description [<branchname>]
  51. .fi
  52. .SH "DESCRIPTION"
  53. .sp
  54. If \fB\-\-list\fR is given, or if there are no non\-option arguments, existing branches are listed; the current branch will be highlighted in green and marked with an asterisk\&. Any branches checked out in linked worktrees will be highlighted in cyan and marked with a plus sign\&. Option \fB\-r\fR causes the remote\-tracking branches to be listed, and option \fB\-a\fR shows both local and remote branches\&.
  55. .sp
  56. If a \fI<pattern>\fR is given, it is used as a shell wildcard to restrict the output to matching branches\&. If multiple patterns are given, a branch is shown if it matches any of the patterns\&.
  57. .sp
  58. Note that when providing a \fI<pattern>\fR, you must use \fB\-\-list\fR; otherwise the command may be interpreted as branch creation\&.
  59. .sp
  60. With \fB\-\-contains\fR, shows only the branches that contain the named commit (in other words, the branches whose tip commits are descendants of the named commit), \fB\-\-no\-contains\fR inverts it\&. With \fB\-\-merged\fR, only branches merged into the named commit (i\&.e\&. the branches whose tip commits are reachable from the named commit) will be listed\&. With \fB\-\-no\-merged\fR only branches not merged into the named commit will be listed\&. If the <commit> argument is missing it defaults to \fBHEAD\fR (i\&.e\&. the tip of the current branch)\&.
  61. .sp
  62. The command\(cqs second form creates a new branch head named <branchname> which points to the current \fBHEAD\fR, or <start\-point> if given\&. As a special case, for <start\-point>, you may use "A\fB\&.\&.\&.\fR\fBB\fR" as a shortcut for the merge base of \fBA\fR and \fBB\fR if there is exactly one merge base\&. You can leave out at most one of \fBA\fR and \fBB\fR, in which case it defaults to \fBHEAD\fR\&.
  63. .sp
  64. Note that this will create the new branch, but it will not switch the working tree to it; use "git switch <newbranch>" to switch to the new branch\&.
  65. .sp
  66. When a local branch is started off a remote\-tracking branch, Git sets up the branch (specifically the \fBbranch\&.\fR\fI<name>\fR\fB\&.remote\fR and \fBbranch\&.\fR\fI<name>\fR\fB\&.merge\fR configuration entries) so that \fIgit pull\fR will appropriately merge from the remote\-tracking branch\&. This behavior may be changed via the global \fBbranch\&.autoSetupMerge\fR configuration flag\&. That setting can be overridden by using the \fB\-\-track\fR and \fB\-\-no\-track\fR options, and changed later using \fBgit\fR \fBbranch\fR \fB\-\-set\-upstream\-to\fR\&.
  67. .sp
  68. With a \fB\-m\fR or \fB\-M\fR option, <oldbranch> will be renamed to <newbranch>\&. If <oldbranch> had a corresponding reflog, it is renamed to match <newbranch>, and a reflog entry is created to remember the branch renaming\&. If <newbranch> exists, \-M must be used to force the rename to happen\&.
  69. .sp
  70. The \fB\-c\fR and \fB\-C\fR options have the exact same semantics as \fB\-m\fR and \fB\-M\fR, except instead of the branch being renamed, it will be copied to a new name, along with its config and reflog\&.
  71. .sp
  72. With a \fB\-d\fR or \fB\-D\fR option, \fI<branchname>\fR 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\&.
  73. .sp
  74. Use \fB\-r\fR together with \fB\-d\fR 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 \fIgit fetch\fR was configured not to fetch them again\&. See also the \fIprune\fR subcommand of \fBgit-remote\fR(1) for a way to clean up all obsolete remote\-tracking branches\&.
  75. .SH "OPTIONS"
  76. .PP
  77. \-d, \-\-delete
  78. .RS 4
  79. Delete a branch\&. The branch must be fully merged in its upstream branch, or in
  80. \fBHEAD\fR
  81. if no upstream was set with
  82. \fB\-\-track\fR
  83. or
  84. \fB\-\-set\-upstream\-to\fR\&.
  85. .RE
  86. .PP
  87. \-D
  88. .RS 4
  89. Shortcut for
  90. \fB\-\-delete\fR
  91. \fB\-\-force\fR\&.
  92. .RE
  93. .PP
  94. \-\-create\-reflog
  95. .RS 4
  96. Create the branch\(cqs reflog\&. This activates recording of all changes made to the branch ref, enabling use of date based sha1 expressions such as "<branchname>@{yesterday}"\&. Note that in non\-bare repositories, reflogs are usually enabled by default by the
  97. \fBcore\&.logAllRefUpdates\fR
  98. config option\&. The negated form
  99. \fB\-\-no\-create\-reflog\fR
  100. only overrides an earlier
  101. \fB\-\-create\-reflog\fR, but currently does not negate the setting of
  102. \fBcore\&.logAllRefUpdates\fR\&.
  103. .RE
  104. .PP
  105. \-f, \-\-force
  106. .RS 4
  107. Reset <branchname> to <start\-point>, even if <branchname> exists already\&. Without
  108. \fB\-f\fR,
  109. \fIgit branch\fR
  110. refuses to change an existing branch\&. In combination with
  111. \fB\-d\fR
  112. (or
  113. \fB\-\-delete\fR), allow deleting the branch irrespective of its merged status, or whether it even points to a valid commit\&. In combination with
  114. \fB\-m\fR
  115. (or
  116. \fB\-\-move\fR), allow renaming the branch even if the new branch name already exists, the same applies for
  117. \fB\-c\fR
  118. (or
  119. \fB\-\-copy\fR)\&.
  120. .sp
  121. Note that
  122. \fIgit branch \-f <branchname> [<start\-point>]\fR, even with
  123. \fI\-f\fR, refuses to change an existing branch
  124. \fI<branchname>\fR
  125. that is checked out in another worktree linked to the same repository\&.
  126. .RE
  127. .PP
  128. \-m, \-\-move
  129. .RS 4
  130. Move/rename a branch, together with its config and reflog\&.
  131. .RE
  132. .PP
  133. \-M
  134. .RS 4
  135. Shortcut for
  136. \fB\-\-move\fR
  137. \fB\-\-force\fR\&.
  138. .RE
  139. .PP
  140. \-c, \-\-copy
  141. .RS 4
  142. Copy a branch, together with its config and reflog\&.
  143. .RE
  144. .PP
  145. \-C
  146. .RS 4
  147. Shortcut for
  148. \fB\-\-copy\fR
  149. \fB\-\-force\fR\&.
  150. .RE
  151. .PP
  152. \-\-color[=<when>]
  153. .RS 4
  154. Color branches to highlight current, local, and remote\-tracking branches\&. The value must be always (the default), never, or auto\&.
  155. .RE
  156. .PP
  157. \-\-no\-color
  158. .RS 4
  159. Turn off branch colors, even when the configuration file gives the default to color output\&. Same as
  160. \fB\-\-color=never\fR\&.
  161. .RE
  162. .PP
  163. \-i, \-\-ignore\-case
  164. .RS 4
  165. Sorting and filtering branches are case insensitive\&.
  166. .RE
  167. .PP
  168. \-\-omit\-empty
  169. .RS 4
  170. Do not print a newline after formatted refs where the format expands to the empty string\&.
  171. .RE
  172. .PP
  173. \-\-column[=<options>], \-\-no\-column
  174. .RS 4
  175. Display branch listing in columns\&. See configuration variable
  176. \fBcolumn\&.branch\fR
  177. for option syntax\&.
  178. \fB\-\-column\fR
  179. and
  180. \fB\-\-no\-column\fR
  181. without options are equivalent to
  182. \fIalways\fR
  183. and
  184. \fInever\fR
  185. respectively\&.
  186. .sp
  187. This option is only applicable in non\-verbose mode\&.
  188. .RE
  189. .PP
  190. \-r, \-\-remotes
  191. .RS 4
  192. List or delete (if used with \-d) the remote\-tracking branches\&. Combine with
  193. \fB\-\-list\fR
  194. to match the optional pattern(s)\&.
  195. .RE
  196. .PP
  197. \-a, \-\-all
  198. .RS 4
  199. List both remote\-tracking branches and local branches\&. Combine with
  200. \fB\-\-list\fR
  201. to match optional pattern(s)\&.
  202. .RE
  203. .PP
  204. \-l, \-\-list
  205. .RS 4
  206. List branches\&. With optional
  207. \fI<pattern>\fR\&.\&.\&., e\&.g\&.
  208. \fBgit\fR
  209. \fBbranch\fR
  210. \fB\-\-list\fR
  211. \*(Aqmaint\-*\*(Aq, list only the branches that match the pattern(s)\&.
  212. .RE
  213. .PP
  214. \-\-show\-current
  215. .RS 4
  216. Print the name of the current branch\&. In detached HEAD state, nothing is printed\&.
  217. .RE
  218. .PP
  219. \-v, \-vv, \-\-verbose
  220. .RS 4
  221. When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any)\&. If given twice, print the path of the linked worktree (if any) and the name of the upstream branch, as well (see also
  222. \fBgit\fR
  223. \fBremote\fR
  224. \fBshow\fR
  225. \fI<remote>\fR)\&. Note that the current worktree\(cqs HEAD will not have its path printed (it will always be your current directory)\&.
  226. .RE
  227. .PP
  228. \-q, \-\-quiet
  229. .RS 4
  230. Be more quiet when creating or deleting a branch, suppressing non\-error messages\&.
  231. .RE
  232. .PP
  233. \-\-abbrev=<n>
  234. .RS 4
  235. In the verbose listing that show the commit object name, show the shortest prefix that is at least
  236. \fI<n>\fR
  237. hexdigits long that uniquely refers the object\&. The default value is 7 and can be overridden by the
  238. \fBcore\&.abbrev\fR
  239. config option\&.
  240. .RE
  241. .PP
  242. \-\-no\-abbrev
  243. .RS 4
  244. Display the full sha1s in the output listing rather than abbreviating them\&.
  245. .RE
  246. .PP
  247. \-t, \-\-track[=(direct|inherit)]
  248. .RS 4
  249. When creating a new branch, set up
  250. \fBbranch\&.\fR\fI<name>\fR\fB\&.remote\fR
  251. and
  252. \fBbranch\&.\fR\fI<name>\fR\fB\&.merge\fR
  253. configuration entries to set "upstream" tracking configuration for the new branch\&. This configuration will tell git to show the relationship between the two branches in
  254. \fBgit\fR
  255. \fBstatus\fR
  256. and
  257. \fBgit\fR
  258. \fBbranch\fR
  259. \fB\-v\fR\&. Furthermore, it directs
  260. \fBgit\fR
  261. \fBpull\fR
  262. without arguments to pull from the upstream when the new branch is checked out\&.
  263. .sp
  264. The exact upstream branch is chosen depending on the optional argument:
  265. \fB\-t\fR,
  266. \fB\-\-track\fR, or
  267. \fB\-\-track=direct\fR
  268. means to use the start\-point branch itself as the upstream;
  269. \fB\-\-track=inherit\fR
  270. means to copy the upstream configuration of the start\-point branch\&.
  271. .sp
  272. The branch\&.autoSetupMerge configuration variable specifies how
  273. \fBgit\fR
  274. \fBswitch\fR,
  275. \fBgit\fR
  276. \fBcheckout\fR
  277. and
  278. \fBgit\fR
  279. \fBbranch\fR
  280. should behave when neither
  281. \fB\-\-track\fR
  282. nor
  283. \fB\-\-no\-track\fR
  284. are specified:
  285. .sp
  286. The default option,
  287. \fBtrue\fR, behaves as though
  288. \fB\-\-track=direct\fR
  289. were given whenever the start\-point is a remote\-tracking branch\&.
  290. \fBfalse\fR
  291. behaves as if
  292. \fB\-\-no\-track\fR
  293. were given\&.
  294. \fBalways\fR
  295. behaves as though
  296. \fB\-\-track=direct\fR
  297. were given\&.
  298. \fBinherit\fR
  299. behaves as though
  300. \fB\-\-track=inherit\fR
  301. were given\&.
  302. \fBsimple\fR
  303. behaves as though
  304. \fB\-\-track=direct\fR
  305. were given only when the start\-point is a remote\-tracking branch and the new branch has the same name as the remote branch\&.
  306. .sp
  307. See
  308. \fBgit-pull\fR(1)
  309. and
  310. \fBgit-config\fR(1)
  311. for additional discussion on how the
  312. \fBbranch\&.\fR\fI<name>\fR\fB\&.remote\fR
  313. and
  314. \fBbranch\&.\fR\fI<name>\fR\fB\&.merge\fR
  315. options are used\&.
  316. .RE
  317. .PP
  318. \-\-no\-track
  319. .RS 4
  320. Do not set up "upstream" configuration, even if the branch\&.autoSetupMerge configuration variable is set\&.
  321. .RE
  322. .PP
  323. \-\-recurse\-submodules
  324. .RS 4
  325. THIS OPTION IS EXPERIMENTAL! Causes the current command to recurse into submodules if
  326. \fBsubmodule\&.propagateBranches\fR
  327. is enabled\&. See
  328. \fBsubmodule\&.propagateBranches\fR
  329. in
  330. \fBgit-config\fR(1)\&. Currently, only branch creation is supported\&.
  331. .sp
  332. When used in branch creation, a new branch <branchname> will be created in the superproject and all of the submodules in the superproject\(cqs <start\-point>\&. In submodules, the branch will point to the submodule commit in the superproject\(cqs <start\-point> but the branch\(cqs tracking information will be set up based on the submodule\(cqs branches and remotes e\&.g\&.
  333. \fBgit\fR
  334. \fBbranch\fR
  335. \fB\-\-recurse\-submodules\fR
  336. \fBtopic\fR
  337. \fBorigin/main\fR
  338. will create the submodule branch "topic" that points to the submodule commit in the superproject\(cqs "origin/main", but tracks the submodule\(cqs "origin/main"\&.
  339. .RE
  340. .PP
  341. \-\-set\-upstream
  342. .RS 4
  343. As this option had confusing syntax, it is no longer supported\&. Please use
  344. \fB\-\-track\fR
  345. or
  346. \fB\-\-set\-upstream\-to\fR
  347. instead\&.
  348. .RE
  349. .PP
  350. \-u <upstream>, \-\-set\-upstream\-to=<upstream>
  351. .RS 4
  352. Set up <branchname>\*(Aqs tracking information so <upstream> is considered <branchname>\*(Aqs upstream branch\&. If no <branchname> is specified, then it defaults to the current branch\&.
  353. .RE
  354. .PP
  355. \-\-unset\-upstream
  356. .RS 4
  357. Remove the upstream information for <branchname>\&. If no branch is specified it defaults to the current branch\&.
  358. .RE
  359. .PP
  360. \-\-edit\-description
  361. .RS 4
  362. Open an editor and edit the text to explain what the branch is for, to be used by various other commands (e\&.g\&.
  363. \fBformat\-patch\fR,
  364. \fBrequest\-pull\fR, and
  365. \fBmerge\fR
  366. (if enabled))\&. Multi\-line explanations may be used\&.
  367. .RE
  368. .PP
  369. \-\-contains [<commit>]
  370. .RS 4
  371. Only list branches which contain the specified commit (HEAD if not specified)\&. Implies
  372. \fB\-\-list\fR\&.
  373. .RE
  374. .PP
  375. \-\-no\-contains [<commit>]
  376. .RS 4
  377. Only list branches which don\(cqt contain the specified commit (HEAD if not specified)\&. Implies
  378. \fB\-\-list\fR\&.
  379. .RE
  380. .PP
  381. \-\-merged [<commit>]
  382. .RS 4
  383. Only list branches whose tips are reachable from the specified commit (HEAD if not specified)\&. Implies
  384. \fB\-\-list\fR\&.
  385. .RE
  386. .PP
  387. \-\-no\-merged [<commit>]
  388. .RS 4
  389. Only list branches whose tips are not reachable from the specified commit (HEAD if not specified)\&. Implies
  390. \fB\-\-list\fR\&.
  391. .RE
  392. .PP
  393. <branchname>
  394. .RS 4
  395. The name of the branch to create or delete\&. The new branch name must pass all checks defined by
  396. \fBgit-check-ref-format\fR(1)\&. Some of these checks may restrict the characters allowed in a branch name\&.
  397. .RE
  398. .PP
  399. <start\-point>
  400. .RS 4
  401. The new branch head will point to this commit\&. It may be given as a branch name, a commit\-id, or a tag\&. If this option is omitted, the current HEAD will be used instead\&.
  402. .RE
  403. .PP
  404. <oldbranch>
  405. .RS 4
  406. The name of an existing branch\&. If this option is omitted, the name of the current branch will be used instead\&.
  407. .RE
  408. .PP
  409. <newbranch>
  410. .RS 4
  411. The new name for an existing branch\&. The same restrictions as for <branchname> apply\&.
  412. .RE
  413. .PP
  414. \-\-sort=<key>
  415. .RS 4
  416. Sort based on the key given\&. Prefix
  417. \fB\-\fR
  418. 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
  419. \fBgit\fR
  420. \fBfor\-each\-ref\fR\&. Sort order defaults to the value configured for the
  421. \fBbranch\&.sort\fR
  422. variable if it exists, or to sorting based on the full refname (including
  423. \fBrefs/\&.\&.\fR\&. prefix)\&. This lists detached HEAD (if present) first, then local branches and finally remote\-tracking branches\&. See
  424. \fBgit-config\fR(1)\&.
  425. .RE
  426. .PP
  427. \-\-points\-at <object>
  428. .RS 4
  429. Only list branches of the given object\&.
  430. .RE
  431. .PP
  432. \-\-format <format>
  433. .RS 4
  434. A string that interpolates %(\fBfieldname\fR) from a branch ref being shown and the object it points at\&. The format is the same as that of
  435. \fBgit-for-each-ref\fR(1)\&.
  436. .RE
  437. .SH "CONFIGURATION"
  438. .sp
  439. \fBpager\&.branch\fR is only respected when listing branches, i\&.e\&., when \fB\-\-list\fR is used or implied\&. The default is to use a pager\&. See \fBgit-config\fR(1)\&.
  440. .sp
  441. Everything above this line in this section isn\(cqt included from the \fBgit-config\fR(1) documentation\&. The content that follows is the same as what\(cqs found there:
  442. .PP
  443. branch\&.autoSetupMerge
  444. .RS 4
  445. Tells
  446. \fIgit branch\fR,
  447. \fIgit switch\fR
  448. and
  449. \fIgit checkout\fR
  450. to set up new branches so that
  451. \fBgit-pull\fR(1)
  452. will appropriately merge from the starting point branch\&. Note that even if this option is not set, this behavior can be chosen per\-branch using the
  453. \fB\-\-track\fR
  454. and
  455. \fB\-\-no\-track\fR
  456. options\&. The valid settings are:
  457. \fBfalse\fR \(em no automatic setup is done;
  458. \fBtrue\fR \(em automatic setup is done when the starting point is a remote\-tracking branch;
  459. \fBalways\fR \(em automatic setup is done when the starting point is either a local branch or remote\-tracking branch;
  460. \fBinherit\fR \(em if the starting point has a tracking configuration, it is copied to the new branch;
  461. \fBsimple\fR \(em automatic setup is done only when the starting point is a remote\-tracking branch and the new branch has the same name as the remote branch\&. This option defaults to true\&.
  462. .RE
  463. .PP
  464. branch\&.autoSetupRebase
  465. .RS 4
  466. When a new branch is created with
  467. \fIgit branch\fR,
  468. \fIgit switch\fR
  469. or
  470. \fIgit checkout\fR
  471. that tracks another branch, this variable tells Git to set up pull to rebase instead of merge (see "branch\&.<name>\&.rebase")\&. When
  472. \fBnever\fR, rebase is never automatically set to true\&. When
  473. \fBlocal\fR, rebase is set to true for tracked branches of other local branches\&. When
  474. \fBremote\fR, rebase is set to true for tracked branches of remote\-tracking branches\&. When
  475. \fBalways\fR, rebase will be set to true for all tracking branches\&. See "branch\&.autoSetupMerge" for details on how to set up a branch to track another branch\&. This option defaults to never\&.
  476. .RE
  477. .PP
  478. branch\&.sort
  479. .RS 4
  480. This variable controls the sort ordering of branches when displayed by
  481. \fBgit-branch\fR(1)\&. Without the "\-\-sort=<value>" option provided, the value of this variable will be used as the default\&. See
  482. \fBgit-for-each-ref\fR(1)
  483. field names for valid values\&.
  484. .RE
  485. .PP
  486. branch\&.<name>\&.remote
  487. .RS 4
  488. When on branch <name>, it tells
  489. \fIgit fetch\fR
  490. and
  491. \fIgit push\fR
  492. which remote to fetch from or push to\&. The remote to push to may be overridden with
  493. \fBremote\&.pushDefault\fR
  494. (for all branches)\&. The remote to push to, for the current branch, may be further overridden by
  495. \fBbranch\&.\fR\fI<name>\fR\fB\&.pushRemote\fR\&. If no remote is configured, or if you are not on any branch and there is more than one remote defined in the repository, it defaults to
  496. \fBorigin\fR
  497. for fetching and
  498. \fBremote\&.pushDefault\fR
  499. for pushing\&. Additionally, \&. (a period) is the current local repository (a dot\-repository), see
  500. \fBbranch\&.\fR\fI<name>\fR\fB\&.merge\fR\*(Aqs final note below\&.
  501. .RE
  502. .PP
  503. branch\&.<name>\&.pushRemote
  504. .RS 4
  505. When on branch <name>, it overrides
  506. \fBbranch\&.\fR\fI<name>\fR\fB\&.remote\fR
  507. for pushing\&. It also overrides
  508. \fBremote\&.pushDefault\fR
  509. for pushing from branch <name>\&. When you pull from one place (e\&.g\&. your upstream) and push to another place (e\&.g\&. your own publishing repository), you would want to set
  510. \fBremote\&.pushDefault\fR
  511. to specify the remote to push to for all branches, and use this option to override it for a specific branch\&.
  512. .RE
  513. .PP
  514. branch\&.<name>\&.merge
  515. .RS 4
  516. Defines, together with branch\&.<name>\&.remote, the upstream branch for the given branch\&. It tells
  517. \fIgit fetch\fR/\fIgit pull\fR/\fIgit rebase\fR
  518. which branch to merge and can also affect
  519. \fIgit push\fR
  520. (see push\&.default)\&. When in branch <name>, it tells
  521. \fIgit fetch\fR
  522. the default refspec to be marked for merging in FETCH_HEAD\&. The value is handled like the remote part of a refspec, and must match a ref which is fetched from the remote given by "branch\&.<name>\&.remote"\&. The merge information is used by
  523. \fIgit pull\fR
  524. (which first calls
  525. \fIgit fetch\fR) to lookup the default branch for merging\&. Without this option,
  526. \fIgit pull\fR
  527. defaults to merge the first refspec fetched\&. Specify multiple values to get an octopus merge\&. If you wish to setup
  528. \fIgit pull\fR
  529. so that it merges into <name> from another branch in the local repository, you can point branch\&.<name>\&.merge to the desired branch, and use the relative path setting \&. (a period) for branch\&.<name>\&.remote\&.
  530. .RE
  531. .PP
  532. branch\&.<name>\&.mergeOptions
  533. .RS 4
  534. Sets default options for merging into branch <name>\&. The syntax and supported options are the same as those of
  535. \fBgit-merge\fR(1), but option values containing whitespace characters are currently not supported\&.
  536. .RE
  537. .PP
  538. branch\&.<name>\&.rebase
  539. .RS 4
  540. When true, rebase the branch <name> on top of the fetched branch, instead of merging the default branch from the default remote when "git pull" is run\&. See "pull\&.rebase" for doing this in a non branch\-specific manner\&.
  541. .sp
  542. When
  543. \fBmerges\fR
  544. (or just
  545. \fIm\fR), pass the
  546. \fB\-\-rebase\-merges\fR
  547. option to
  548. \fIgit rebase\fR
  549. so that the local merge commits are included in the rebase (see
  550. \fBgit-rebase\fR(1)
  551. for details)\&.
  552. .sp
  553. When the value is
  554. \fBinteractive\fR
  555. (or just
  556. \fIi\fR), the rebase is run in interactive mode\&.
  557. .sp
  558. \fBNOTE\fR: this is a possibly dangerous operation; do
  559. \fBnot\fR
  560. use it unless you understand the implications (see
  561. \fBgit-rebase\fR(1)
  562. for details)\&.
  563. .RE
  564. .PP
  565. branch\&.<name>\&.description
  566. .RS 4
  567. Branch description, can be edited with
  568. \fBgit\fR
  569. \fBbranch\fR
  570. \fB\-\-edit\-description\fR\&. Branch description is automatically added to the format\-patch cover letter or request\-pull summary\&.
  571. .RE
  572. .SH "EXAMPLES"
  573. .PP
  574. Start development from a known tag
  575. .RS 4
  576. .sp
  577. .if n \{\
  578. .RS 4
  579. .\}
  580. .nf
  581. $ git clone git://git\&.kernel\&.org/pub/scm/\&.\&.\&./linux\-2\&.6 my2\&.6
  582. $ cd my2\&.6
  583. $ git branch my2\&.6\&.14 v2\&.6\&.14 \fB(1)\fR
  584. $ git switch my2\&.6\&.14
  585. .fi
  586. .if n \{\
  587. .RE
  588. .\}
  589. .TS
  590. tab(:);
  591. r lw(\n(.lu*75u/100u).
  592. \fB1.\fR\h'-2n':T{
  593. This step and the next one could be combined into a single step with "checkout \-b my2\&.6\&.14 v2\&.6\&.14"\&.
  594. T}
  595. .TE
  596. .RE
  597. .PP
  598. Delete an unneeded branch
  599. .RS 4
  600. .sp
  601. .if n \{\
  602. .RS 4
  603. .\}
  604. .nf
  605. $ git clone git://git\&.kernel\&.org/\&.\&.\&./git\&.git my\&.git
  606. $ cd my\&.git
  607. $ git branch \-d \-r origin/todo origin/html origin/man \fB(1)\fR
  608. $ git branch \-D test \fB(2)\fR
  609. .fi
  610. .if n \{\
  611. .RE
  612. .\}
  613. .TS
  614. tab(:);
  615. r lw(\n(.lu*75u/100u).
  616. \fB1.\fR\h'-2n':T{
  617. Delete the remote\-tracking branches "todo", "html" and "man"\&. The next
  618. \fIfetch\fR
  619. or
  620. \fIpull\fR
  621. will create them again unless you configure them not to\&. See
  622. \fBgit-fetch\fR(1)\&.
  623. T}
  624. \fB2.\fR\h'-2n':T{
  625. Delete the "test" branch even if the "master" branch (or whichever branch is currently checked out) does not have all commits from the test branch\&.
  626. T}
  627. .TE
  628. .RE
  629. .PP
  630. Listing branches from a specific remote
  631. .RS 4
  632. .sp
  633. .if n \{\
  634. .RS 4
  635. .\}
  636. .nf
  637. $ git branch \-r \-l \*(Aq<remote>/<pattern>\*(Aq \fB(1)\fR
  638. $ git for\-each\-ref \*(Aqrefs/remotes/<remote>/<pattern>\*(Aq \fB(2)\fR
  639. .fi
  640. .if n \{\
  641. .RE
  642. .\}
  643. .TS
  644. tab(:);
  645. r lw(\n(.lu*75u/100u).
  646. \fB1.\fR\h'-2n':T{
  647. Using
  648. \fB\-a\fR
  649. would conflate <remote> with any local branches you happen to have been prefixed with the same <remote> pattern\&.
  650. T}
  651. \fB2.\fR\h'-2n':T{
  652. \fBfor\-each\-ref\fR
  653. can take a wide range of options\&. See
  654. \fBgit-for-each-ref\fR(1)
  655. T}
  656. .TE
  657. .RE
  658. .sp
  659. Patterns will normally need quoting\&.
  660. .SH "NOTES"
  661. .sp
  662. If you are creating a branch that you want to switch to immediately, it is easier to use the "git switch" command with its \fB\-c\fR option to do the same thing with a single command\&.
  663. .sp
  664. The options \fB\-\-contains\fR, \fB\-\-no\-contains\fR, \fB\-\-merged\fR and \fB\-\-no\-merged\fR serve four related but different purposes:
  665. .sp
  666. .RS 4
  667. .ie n \{\
  668. \h'-04'\(bu\h'+03'\c
  669. .\}
  670. .el \{\
  671. .sp -1
  672. .IP \(bu 2.3
  673. .\}
  674. \fB\-\-contains\fR
  675. \fI<commit>\fR
  676. is used to find all branches which will need special attention if <commit> were to be rebased or amended, since those branches contain the specified <commit>\&.
  677. .RE
  678. .sp
  679. .RS 4
  680. .ie n \{\
  681. \h'-04'\(bu\h'+03'\c
  682. .\}
  683. .el \{\
  684. .sp -1
  685. .IP \(bu 2.3
  686. .\}
  687. \fB\-\-no\-contains\fR
  688. \fI<commit>\fR
  689. is the inverse of that, i\&.e\&. branches that don\(cqt contain the specified <commit>\&.
  690. .RE
  691. .sp
  692. .RS 4
  693. .ie n \{\
  694. \h'-04'\(bu\h'+03'\c
  695. .\}
  696. .el \{\
  697. .sp -1
  698. .IP \(bu 2.3
  699. .\}
  700. \fB\-\-merged\fR
  701. is used to find all branches which can be safely deleted, since those branches are fully contained by HEAD\&.
  702. .RE
  703. .sp
  704. .RS 4
  705. .ie n \{\
  706. \h'-04'\(bu\h'+03'\c
  707. .\}
  708. .el \{\
  709. .sp -1
  710. .IP \(bu 2.3
  711. .\}
  712. \fB\-\-no\-merged\fR
  713. is used to find branches which are candidates for merging into HEAD, since those branches are not fully contained by HEAD\&.
  714. .RE
  715. .sp
  716. When combining multiple \fB\-\-contains\fR and \fB\-\-no\-contains\fR filters, only references that contain at least one of the \fB\-\-contains\fR commits and contain none of the \fB\-\-no\-contains\fR commits are shown\&.
  717. .sp
  718. When combining multiple \fB\-\-merged\fR and \fB\-\-no\-merged\fR filters, only references that are reachable from at least one of the \fB\-\-merged\fR commits and from none of the \fB\-\-no\-merged\fR commits are shown\&.
  719. .SH "SEE ALSO"
  720. .sp
  721. \fBgit-check-ref-format\fR(1), \fBgit-fetch\fR(1), \fBgit-remote\fR(1), \m[blue]\fB\(lqUnderstanding history: What is a branch?\(rq\fR\m[]\&\s-2\u[1]\d\s+2 in the Git User\(cqs Manual\&.
  722. .SH "GIT"
  723. .sp
  724. Part of the \fBgit\fR(1) suite
  725. .SH "NOTES"
  726. .IP " 1." 4
  727. \(lqUnderstanding history: What is
  728. a branch?\(rq
  729. .RS 4
  730. \%git-htmldocs/user-manual.html#what-is-a-branch
  731. .RE