1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
'\" t
.\" Title: git-new-branch
.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 05/07/2025
.\" Manual: Chromium depot_tools Manual
.\" Source: depot_tools fab0a429
.\" Language: English
.\"
.TH "GIT\-NEW\-BRANCH" "1" "05/07/2025" "depot_tools fab0a429" "Chromium depot_tools Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-new-branch \- Create and switch to a new branch with correct tracking information\&.
.SH "SYNOPSIS"
.sp
.nf
\fIgit new\-branch\fR <branch_name>
\fIgit new\-branch\fR \-\-upstream_current <branch_name>
\fIgit new\-branch\fR \-\-upstream <REF> <branch_name>
\fIgit new\-branch\fR \-\-lkgr <branch_name>
\fIgit new\-branch\fR \-\-inject_current <branch_name>
.fi
.sp
.SH "DESCRIPTION"
.sp
Creates a new branch\&. By default the new branch will track the configured upstream for the repo (defaults to \fIorigin/main\fR)\&. If one of the other options is specified, it will track that other ref instead\&.
.sp
Conceptually, each branch in your repo represents one \fIChange List (CL)\fR\&. If you have many independent CLs (i\&.e\&. the changes in one do not interact with/depend on the changes in another), then you should create them as new branches tracking the default upstream (i\&.e\&. \fBgit new\-branch <branch_name>\fR)\&. If you have features which depend on each other, you should create stacked branches using \fBgit new\-branch \-\-upstream_current <branch_name>\fR\&.
.SH "OPTIONS"
.PP
\-\-upstream_current
.RS 4
Set the tracking (upstream) branch to the currently\-checked\-out branch\&.
.RE
.PP
\-\-upstream <REF>
.RS 4
Set the tracking (upstream) branch to <REF>\&. <REF> may be a local branch, remote branch, or a tag\&.
.RE
.PP
\-\-lkgr
.RS 4
Alias for
\fB\-\-upstream lkgr\fR\&.
.RE
.PP
\-\-inject_current
.RS 4
Set the tracking (upstream) branch of the newly\-created branch to the tracking (upstream) branch of the currently\-checked\-out branch and set the tracking (upstream) branch of the currently\-checked\-out branch to the newly\-created branch\&.
.sp
.if n \{\
.RS 4
.\}
.nf
Before: current > upstream
After: current > new > upstream
.fi
.if n \{\
.RE
.\}
.RE
.PP
<branch_name>
.RS 4
The name for the new branch\&.
.RE
.SH "CONFIGURATION VARIABLES"
.SS "depot\-tools\&.upstream"
.sp
This configures the default \fIupstream\fR for all new branches\&. If it is unset, it defaults to \fIorigin\fR\*(Aqs default branch or \fIorigin/main\fR if that can\(cqt be found\&. This is considered to be the \fIroot\fR branch\&.
.SH "EXAMPLE"
.sp
.sp
.if n \{\
.RS 4
.\}
.nf
\fB$ git map\-branches \-v\fR
origin/main
cool_feature [ 4 commits ]
subfeature [ 2 commits | behind 1 ]
fixit [ 2 commits ]
\fB frozen_branch * [ 3 commits ]
\fR
\fB$ git new\-branch independent_cl\fR
\fB$ git map\-branches \-v\fR
\fBorigin/main
\fR cool_feature [ 4 commits ]
subfeature [ 2 commits | behind 1 ]
fixit [ 2 commits ]
frozen_branch [ 3 commits ]
\fB independent_cl *
\fR
\fB$ vi foo && git add \-A && git commit \-m foo\fR
\fB$ git map\-branches \-v\fR
origin/main
cool_feature [ 4 commits ]
subfeature [ 2 commits | behind 1 ]
fixit [ 2 commits ]
frozen_branch [ 3 commits ]
\fB independent_cl * [ 1 commit ]
\fR
\fB$ git new\-branch \-\-upstream subfeature nested_cl\fR
\fB$ git map\-branches \-v\fR
origin/main
cool_feature [ 4 commits ]
\fB subfeature [ 2 commits | behind 1 ] \fR\fB\fB(1)\fR\fR\fB
nested_cl *
\fR fixit [ 2 commits ]
frozen_branch [ 3 commits ]
independent_cl [ 1 commit ]
\fB$ git checkout cool_feature\fR
Switched to branch \*(Aqcool_feature\*(Aq
Your branch is ahead of \*(Aqorigin/main\*(Aq by 4 commits\&.
(use "git push" to publish your local commits)
\fB$ git new\-branch \-\-upstream_current cl_depends_on_cool_feature\fR
\fB$ git map\-branches \-v\fR
origin/main
\fB cool_feature [ 4 commits ]
cl_depends_on_cool_feature *
\fR subfeature [ 2 commits | behind 1 ]
nested_cl
fixit [ 2 commits ]
frozen_branch [ 3 commits ]
independent_cl [ 1 commit ]
\fB$ git checkout subfeature\fR
Your branch and \*(Aqcool_feature\*(Aq have diverged,
and have 2 and 1 different commits each, respectively\&.
(use "git pull" if you want to integrate the remote branch with yours)
\fB$ git new\-branch \-\-inject_current injected_cl\fR
\fB$ git map\-branches \-v\fR
origin/main
\fB cool_feature [ 4 commits ]
cl_depends_on_cool_feature
injected_cl *
\fR subfeature [ 2 commits | behind 1 ]
nested_cl
fixit [ 2 commits ]
frozen_branch [ 3 commits ]
independent_cl [ 1 commit ]
.fi
.if n \{\
.RE
.\}
.sp
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 1." 4.2
.\}
Note that these branches are cyan because they are currently the same
\fIcommit\fR
object\&. See
\fBgit-map-branches\fR(1)
for more detail\&.
.RE
.SH "SUGGESTED ALIASES"
.sp
Some common short\-hand aliases\&. Feel free to add these to your \fI~/\&.gitconfig\fR file\&.
.sp
.if n \{\
.RS 4
.\}
.nf
[alias]
nb = new\-branch
tb = new\-branch \-\-upstream_current \fB(1)\fR
.fi
.if n \{\
.RE
.\}
.sp
.sp
\fB1. \fRmnemonic: tb \(-> "track branch"
.br
.SH "SEE ALSO"
.sp
\fBgit-rebase-update\fR(1), \fBgit-reparent-branch\fR(1), \fBgit-rename-branch\fR(1), \fBgit-upstream-diff\fR(1)
.SH "CHROMIUM DEPOT_TOOLS"
.sp
Part of the chromium \fBdepot_tools\fR(7) suite\&. These tools are meant to assist with the development of chromium and related projects\&. Download the tools by checking out the \m[blue]\fBgit repository\fR\m[]\&\s-2\u[1]\d\s+2\&.
.SH "NOTES"
.IP " 1." 4
git repository
.RS 4
\%https://chromium.googlesource.com/chromium/tools/depot_tools.git
.RE
|