Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | git-show-branch(1) |
| 2 | ================== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 0107892 | 2006-03-10 00:31:47 | [diff] [blame] | 6 | git-show-branch - Show branches and their commits |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 10 | [verse] |
Junio C Hamano | cf9c773 | 2022-10-28 18:56:06 | [diff] [blame] | 11 | 'git show-branch' [-a | --all] [-r | --remotes] [--topo-order | --date-order] |
Junio C Hamano | 4aa0bcc | 2010-03-03 05:13:12 | [diff] [blame] | 12 | [--current] [--color[=<when>] | --no-color] [--sparse] |
Junio C Hamano | 2bb1310 | 2006-03-06 07:10:21 | [diff] [blame] | 13 | [--more=<n> | --list | --independent | --merge-base] |
Junio C Hamano | cca5661 | 2009-06-03 08:27:33 | [diff] [blame] | 14 | [--no-name | --sha1-name] [--topics] |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 15 | [(<rev> | <glob>)...] |
Junio C Hamano | cf9c773 | 2022-10-28 18:56:06 | [diff] [blame] | 16 | 'git show-branch' (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 17 | |
| 18 | DESCRIPTION |
| 19 | ----------- |
| 20 | |
| 21 | Shows the commit ancestry graph starting from the commits named |
Junio C Hamano | 94d00a5 | 2018-10-30 07:34:40 | [diff] [blame] | 22 | with <rev>s or <glob>s (or all refs under refs/heads |
Junio C Hamano | 4fdccb2 | 2010-02-19 09:58:14 | [diff] [blame] | 23 | and/or refs/tags) semi-visually. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 24 | |
Junio C Hamano | ae0f901 | 2024-07-16 22:52:00 | [diff] [blame] | 25 | It cannot show more than 26 branches and commits at a time. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 26 | |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 27 | It uses `showbranch.default` multi-valued configuration items if |
Junio C Hamano | d75148a | 2014-04-08 19:48:38 | [diff] [blame] | 28 | no <rev> or <glob> is given on the command line. |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 29 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 30 | |
| 31 | OPTIONS |
| 32 | ------- |
| 33 | <rev>:: |
Junio C Hamano | e3f080d | 2013-04-22 02:27:13 | [diff] [blame] | 34 | Arbitrary extended SHA-1 expression (see linkgit:gitrevisions[7]) |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame] | 35 | that typically names a branch head or a tag. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 36 | |
| 37 | <glob>:: |
| 38 | A glob pattern that matches branch or tag names under |
Junio C Hamano | 4fdccb2 | 2010-02-19 09:58:14 | [diff] [blame] | 39 | refs/. For example, if you have many topic |
| 40 | branches under refs/heads/topic, giving |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 41 | `topic/*` would show all of them. |
| 42 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 43 | -r:: |
| 44 | --remotes:: |
Junio C Hamano | 30e1db1 | 2006-12-23 10:29:52 | [diff] [blame] | 45 | Show the remote-tracking branches. |
| 46 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 47 | -a:: |
| 48 | --all:: |
Junio C Hamano | 30e1db1 | 2006-12-23 10:29:52 | [diff] [blame] | 49 | Show both remote-tracking branches and local branches. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 50 | |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 51 | --current:: |
| 52 | With this option, the command includes the current |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 53 | branch in the list of revs to be shown when it is not |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 54 | given on the command line. |
| 55 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 56 | --topo-order:: |
| 57 | By default, the branches and their commits are shown in |
| 58 | reverse chronological order. This option makes them |
| 59 | appear in topological order (i.e., descendant commits |
| 60 | are shown before their parents). |
| 61 | |
Junio C Hamano | cca5661 | 2009-06-03 08:27:33 | [diff] [blame] | 62 | --date-order:: |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 63 | This option is similar to `--topo-order` in the sense that no |
Junio C Hamano | cca5661 | 2009-06-03 08:27:33 | [diff] [blame] | 64 | parent comes before all of its children, but otherwise commits |
| 65 | are ordered according to their commit date. |
| 66 | |
Junio C Hamano | 872c568 | 2006-07-07 06:05:40 | [diff] [blame] | 67 | --sparse:: |
| 68 | By default, the output omits merges that are reachable |
| 69 | from only one tip being shown. This option makes them |
| 70 | visible. |
| 71 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 72 | --more=<n>:: |
| 73 | Usually the command stops output upon showing the commit |
| 74 | that is the common ancestor of all the branches. This |
| 75 | flag tells the command to go <n> more common commits |
| 76 | beyond that. When <n> is negative, display only the |
Junio C Hamano | a7b2c10 | 2023-06-13 21:00:15 | [diff] [blame] | 77 | <ref>s given, without showing the commit ancestry tree. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 78 | |
| 79 | --list:: |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 80 | Synonym to `--more=-1` |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 81 | |
| 82 | --merge-base:: |
Junio C Hamano | fd9274d | 2009-08-05 21:21:39 | [diff] [blame] | 83 | Instead of showing the commit list, determine possible |
| 84 | merge bases for the specified commits. All merge bases |
| 85 | will be contained in all specified commits. This is |
| 86 | different from how linkgit:git-merge-base[1] handles |
| 87 | the case of three or more commits. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 88 | |
| 89 | --independent:: |
Junio C Hamano | a7b2c10 | 2023-06-13 21:00:15 | [diff] [blame] | 90 | Among the <ref>s given, display only the ones that cannot be |
| 91 | reached from any other <ref>. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 92 | |
| 93 | --no-name:: |
| 94 | Do not show naming strings for each commit. |
| 95 | |
| 96 | --sha1-name:: |
| 97 | Instead of naming the commits using the path to reach |
| 98 | them from heads (e.g. "master~2" to mean the grandparent |
| 99 | of "master"), name them with the unique prefix of their |
| 100 | object names. |
| 101 | |
Junio C Hamano | 52401ef | 2006-12-19 00:54:38 | [diff] [blame] | 102 | --topics:: |
| 103 | Shows only commits that are NOT on the first branch given. |
| 104 | This helps track topic branches by hiding any commit that |
| 105 | is already in the main line of development. When given |
| 106 | "git show-branch --topics master topic1 topic2", this |
| 107 | will show the revisions given by "git rev-list {caret}master |
| 108 | topic1 topic2" |
| 109 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 110 | -g:: |
Junio C Hamano | 16cf158 | 2007-02-05 07:21:48 | [diff] [blame] | 111 | --reflog[=<n>[,<base>]] [<ref>]:: |
Junio C Hamano | db450ba | 2007-01-21 08:57:14 | [diff] [blame] | 112 | Shows <n> most recent ref-log entries for the given |
| 113 | ref. If <base> is given, <n> entries going back from |
Junio C Hamano | fa0d4cf | 2007-01-25 02:23:58 | [diff] [blame] | 114 | that entry. <base> can be specified as count or date. |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 115 | When no explicit <ref> parameter is given, it defaults to the |
Junio C Hamano | 16cf158 | 2007-02-05 07:21:48 | [diff] [blame] | 116 | current branch (or `HEAD` if it is detached). |
Junio C Hamano | d793de5 | 2006-12-26 09:11:43 | [diff] [blame] | 117 | |
Junio C Hamano | 4aa0bcc | 2010-03-03 05:13:12 | [diff] [blame] | 118 | --color[=<when>]:: |
Junio C Hamano | 52ba295 | 2009-05-18 17:43:02 | [diff] [blame] | 119 | Color the status sign (one of these: `*` `!` `+` `-`) of each commit |
| 120 | corresponding to the branch it's in. |
Junio C Hamano | 4aa0bcc | 2010-03-03 05:13:12 | [diff] [blame] | 121 | The value must be always (the default), never, or auto. |
Junio C Hamano | 52ba295 | 2009-05-18 17:43:02 | [diff] [blame] | 122 | |
| 123 | --no-color:: |
| 124 | Turn off colored output, even when the configuration file gives the |
| 125 | default to color output. |
Junio C Hamano | 4aa0bcc | 2010-03-03 05:13:12 | [diff] [blame] | 126 | Same as `--color=never`. |
Junio C Hamano | 52ba295 | 2009-05-18 17:43:02 | [diff] [blame] | 127 | |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 128 | Note that --more, --list, --independent, and --merge-base options |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 129 | are mutually exclusive. |
| 130 | |
| 131 | |
| 132 | OUTPUT |
| 133 | ------ |
Junio C Hamano | a7b2c10 | 2023-06-13 21:00:15 | [diff] [blame] | 134 | |
| 135 | Given N <ref>s, the first N lines are the one-line description from |
| 136 | their commit message. The branch head that is pointed at by |
| 137 | $GIT_DIR/HEAD is prefixed with an asterisk `*` character while other |
| 138 | heads are prefixed with a `!` character. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 139 | |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 140 | Following these N lines, a one-line log for each commit is |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 141 | displayed, indented N places. If a commit is on the I-th |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 142 | branch, the I-th indentation character shows a `+` sign; |
| 143 | otherwise it shows a space. Merge commits are denoted by |
| 144 | a `-` sign. Each commit shows a short name that |
Junio C Hamano | e3f080d | 2013-04-22 02:27:13 | [diff] [blame] | 145 | can be used as an extended SHA-1 to name that commit. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 146 | |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 147 | The following example shows three branches, "master", "fixes", |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 148 | and "mhf": |
| 149 | |
| 150 | ------------------------------------------------ |
| 151 | $ git show-branch master fixes mhf |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 152 | * [master] Add 'git show-branch'. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 153 | ! [fixes] Introduce "reset type" flag to "git reset" |
| 154 | ! [mhf] Allow "+remote:local" refspec to cause --force when fetching. |
| 155 | --- |
| 156 | + [mhf] Allow "+remote:local" refspec to cause --force when fetching. |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 157 | + [mhf~1] Use git-octopus when pulling more than one head. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 158 | + [fixes] Introduce "reset type" flag to "git reset" |
| 159 | + [mhf~2] "git fetch --force". |
| 160 | + [mhf~3] Use .git/remote/origin, not .git/branches/origin. |
| 161 | + [mhf~4] Make "git pull" and "git fetch" default to origin |
| 162 | + [mhf~5] Infamous 'octopus merge' |
| 163 | + [mhf~6] Retire git-parse-remote. |
| 164 | + [mhf~7] Multi-head fetch. |
| 165 | + [mhf~8] Start adding the $GIT_DIR/remotes/ support. |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 166 | *++ [master] Add 'git show-branch'. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 167 | ------------------------------------------------ |
| 168 | |
| 169 | These three branches all forked from a common commit, [master], |
Junio C Hamano | 2ba1471 | 2019-04-25 10:12:27 | [diff] [blame] | 170 | whose commit message is "Add \'git show-branch'". |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 171 | The "fixes" branch adds one commit "Introduce "reset type" flag to |
| 172 | "git reset"". The "mhf" branch adds many other commits. |
| 173 | The current branch is "master". |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 174 | |
| 175 | |
Junio C Hamano | b9d9d90 | 2018-05-23 07:07:42 | [diff] [blame] | 176 | EXAMPLES |
| 177 | -------- |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 178 | |
| 179 | If you keep your primary branches immediately under |
Junio C Hamano | 4fdccb2 | 2010-02-19 09:58:14 | [diff] [blame] | 180 | `refs/heads`, and topic branches in subdirectories of |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 181 | it, having the following in the configuration file may help: |
| 182 | |
| 183 | ------------ |
| 184 | [showbranch] |
| 185 | default = --topo-order |
| 186 | default = heads/* |
| 187 | |
| 188 | ------------ |
| 189 | |
Junio C Hamano | 2b13527 | 2006-03-18 07:45:42 | [diff] [blame] | 190 | With this, `git show-branch` without extra parameters would show |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 191 | only the primary branches. In addition, if you happen to be on |
| 192 | your topic branch, it is shown as well. |
| 193 | |
Junio C Hamano | db450ba | 2007-01-21 08:57:14 | [diff] [blame] | 194 | ------------ |
Junio C Hamano | f62a11d | 2008-12-21 12:16:36 | [diff] [blame] | 195 | $ git show-branch --reflog="10,1 hour ago" --list master |
Junio C Hamano | db450ba | 2007-01-21 08:57:14 | [diff] [blame] | 196 | ------------ |
| 197 | |
| 198 | shows 10 reflog entries going back from the tip as of 1 hour ago. |
| 199 | Without `--list`, the output also shows how these tips are |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 200 | topologically related to each other. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 201 | |
Junio C Hamano | ba8baee | 2022-09-14 20:25:23 | [diff] [blame] | 202 | CONFIGURATION |
| 203 | ------------- |
| 204 | |
| 205 | include::includes/cmd-config-section-all.txt[] |
| 206 | |
| 207 | include::config/showbranch.txt[] |
| 208 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 209 | GIT |
| 210 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 211 | Part of the linkgit:git[1] suite |