Skip to content

Commit 6831776

Browse files
committed
docs/howto: use main when talking about the main branch
Technically, some of these documents are mere copies from the Git mailing list. As such, one might argue that they should not be modified. However, they were added with the intention of documenting certain things, and therefore it makes sense to keep them up to date. Note: this patch _still_ leaves out documents that talk about git.git's own branches, as we did not rename `master` (at least for now). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 155112e commit 6831776

File tree

7 files changed

+68
-68
lines changed

7 files changed

+68
-68
lines changed

Documentation/howto/keep-canonical-history-correct.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ this:
136136
------------
137137
C0--C1--C2 topic-c
138138
/
139-
---o---o---A master
139+
---o---o---A main
140140
\
141141
B0--B1--B2 topic-b
142142
------------
@@ -146,26 +146,26 @@ so:
146146

147147
------------
148148
$ git clone $URL work && cd work
149-
$ git checkout -b topic-b master
149+
$ git checkout -b topic-b main
150150
$ ... work to create B0, B1 and B2 to complete one theme
151-
$ git checkout -b topic-c master
151+
$ git checkout -b topic-c main
152152
$ ... same for the theme of topic-c
153153
------------
154154

155155
And then
156156

157157
------------
158-
$ git checkout master
158+
$ git checkout main
159159
$ git pull --ff-only
160160
------------
161161

162-
would grab `X`, `Y` and `Z` from the upstream and advance your master
162+
would grab `X`, `Y` and `Z` from the upstream and advance your main
163163
branch:
164164

165165
------------
166166
C0--C1--C2 topic-c
167167
/
168-
---o---o---A---X---Y---Z master
168+
---o---o---A---X---Y---Z main
169169
\
170170
B0--B1--B2 topic-b
171171
------------
@@ -194,10 +194,10 @@ topic-c, somebody again advanced the history in the central repository
194194
to put `W` on top of `Z`, and make your `git push` fail.
195195

196196
In such a case, you would rewind to discard `M` and `N`, update the
197-
tip of your 'master' again and redo the two merges:
197+
tip of your 'main' again and redo the two merges:
198198

199199
------------
200-
$ git reset --hard origin/master
200+
$ git reset --hard origin/main
201201
$ git pull --ff-only
202202
$ git merge topic-b
203203
$ git merge topic-c

Documentation/howto/revert-a-faulty-merge.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ How to revert a faulty merge
1414

1515
Alan <[email protected]> said:
1616

17-
I have a master branch. We have a branch off of that that some
17+
I have a main branch. We have a branch off of that that some
1818
developers are doing work on. They claim it is ready. We merge it
19-
into the master branch. It breaks something so we revert the merge.
19+
into the main branch. It breaks something so we revert the merge.
2020
They make changes to the code. they get it to a point where they say
2121
it is ok and we merge again.
2222

2323
When examined, we find that code changes made before the revert are
24-
not in the master branch, but code changes after are in the master
24+
not in the main branch, but code changes after are in the main
2525
branch.
2626

2727
and asked for help recovering from this situation.

Documentation/howto/revert-branch-rebase.txt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@ Message-ID: <[email protected]>
1111
How to revert an existing commit
1212
================================
1313

14-
One of the changes I pulled into the 'master' branch turns out to
14+
One of the changes I pulled into the 'main' branch turns out to
1515
break building Git with GCC 2.95. While they were well-intentioned
1616
portability fixes, keeping things working with gcc-2.95 was also
17-
important. Here is what I did to revert the change in the 'master'
17+
important. Here is what I did to revert the change in the 'main'
1818
branch and to adjust the 'seen' branch, using core Git tools and
1919
barebone Porcelain.
2020

2121
First, prepare a throw-away branch in case I screw things up.
2222

2323
------------------------------------------------
24-
$ git checkout -b revert-c99 master
24+
$ git checkout -b revert-c99 main
2525
------------------------------------------------
2626

2727
Now I am on the 'revert-c99' branch. Let's figure out which commit to
28-
revert. I happen to know that the top of the 'master' branch is a
28+
revert. I happen to know that the top of the 'main' branch is a
2929
merge, and its second parent (i.e. foreign commit I merged from) has
3030
the change I would want to undo. Further I happen to know that that
3131
merge introduced 5 commits or so:
3232

3333
------------------------------------------------
34-
$ git show-branch --more=4 master master^2 | head
35-
* [master] Merge refs/heads/portable from http://www.cs.berkeley....
36-
! [master^2] Replace C99 array initializers with code.
34+
$ git show-branch --more=4 main main^2 | head
35+
* [main] Merge refs/heads/portable from http://www.cs.berkeley....
36+
! [main^2] Replace C99 array initializers with code.
3737
--
38-
- [master] Merge refs/heads/portable from http://www.cs.berkeley....
39-
*+ [master^2] Replace C99 array initializers with code.
40-
*+ [master^2~1] Replace unsetenv() and setenv() with older putenv().
41-
*+ [master^2~2] Include sys/time.h in daemon.c.
42-
*+ [master^2~3] Fix ?: statements.
43-
*+ [master^2~4] Replace zero-length array decls with [].
44-
* [master~1] tutorial note about git branch
38+
- [main] Merge refs/heads/portable from http://www.cs.berkeley....
39+
*+ [main^2] Replace C99 array initializers with code.
40+
*+ [main^2~1] Replace unsetenv() and setenv() with older putenv().
41+
*+ [main^2~2] Include sys/time.h in daemon.c.
42+
*+ [main^2~3] Fix ?: statements.
43+
*+ [main^2~4] Replace zero-length array decls with [].
44+
* [main~1] tutorial note about git branch
4545
------------------------------------------------
4646

4747
The '--more=4' above means "after we reach the merge base of refs,
@@ -51,15 +51,15 @@ git.git repository, so this would show everything on both branches
5151
since then. I just limited the output to the first handful using
5252
'head'.
5353

54-
Now I know 'master^2~4' (pronounce it as "find the second parent of
55-
the 'master', and then go four generations back following the first
54+
Now I know 'main^2~4' (pronounce it as "find the second parent of
55+
the 'main', and then go four generations back following the first
5656
parent") is the one I would want to revert. Since I also want to say
5757
why I am reverting it, the '-n' flag is given to 'git revert'. This
5858
prevents it from actually making a commit, and instead 'git revert'
5959
leaves the commit log message it wanted to use in '.msg' file:
6060

6161
------------------------------------------------
62-
$ git revert -n master^2~4
62+
$ git revert -n main^2~4
6363
$ cat .msg
6464
Revert "Replace zero-length array decls with []."
6565

@@ -79,12 +79,12 @@ $ git commit -a -s ;# read .msg into the log,
7979
------------------------------------------------
8080

8181
I could have screwed up in any of the above steps, but in the worst
82-
case I could just have done 'git checkout master' to start over.
82+
case I could just have done 'git checkout main' to start over.
8383
Fortunately I did not have to; what I have in the current branch
84-
'revert-c99' is what I want. So merge that back into 'master':
84+
'revert-c99' is what I want. So merge that back into 'main':
8585

8686
------------------------------------------------
87-
$ git checkout master
87+
$ git checkout main
8888
$ git merge revert-c99 ;# this should be a fast-forward
8989
Updating from 10d781b9caa4f71495c7b34963bef137216f86a8 to e3a693c...
9090
cache.h | 8 ++++----
@@ -96,10 +96,10 @@ Updating from 10d781b9caa4f71495c7b34963bef137216f86a8 to e3a693c...
9696
------------------------------------------------
9797

9898
There is no need to redo the test at this point. We fast-forwarded
99-
and we know 'master' matches 'revert-c99' exactly. In fact:
99+
and we know 'main' matches 'revert-c99' exactly. In fact:
100100

101101
------------------------------------------------
102-
$ git diff master..revert-c99
102+
$ git diff main..revert-c99
103103
------------------------------------------------
104104

105105
says nothing.
@@ -109,7 +109,7 @@ Then we rebase the 'seen' branch as usual.
109109
------------------------------------------------
110110
$ git checkout seen
111111
$ git tag seen-anchor seen
112-
$ git rebase master
112+
$ git rebase main
113113
* Applying: Redo "revert" using three-way merge machinery.
114114
First trying simple merge strategy to cherry-pick.
115115
* Applying: Remove git-apply-patch-script.
@@ -131,7 +131,7 @@ The temporary tag 'seen-anchor' is me just being careful, in case 'git
131131
rebase' screws up. After this, I can do these for sanity check:
132132

133133
------------------------------------------------
134-
$ git diff seen-anchor..seen ;# make sure we got the master fix.
134+
$ git diff seen-anchor..seen ;# make sure we got the main fix.
135135
$ make CC=gcc-2.95 clean test ;# make sure it fixed the breakage.
136136
$ make clean test ;# make sure it did not cause other breakage.
137137
------------------------------------------------
@@ -150,11 +150,11 @@ be some days off:
150150

151151
------------------------------------------------
152152
$ git checkout rc
153-
$ git pull . master
153+
$ git pull . main
154154
Packing 0 objects
155155
Unpacking 0 objects
156156

157-
* commit-ish: e3a693c... refs/heads/master from .
157+
* commit-ish: e3a693c... refs/heads/main from .
158158
Trying to merge e3a693c... into 8c1f5f0... using 10d781b...
159159
Committed merge 7fb9b7262a1d1e0a47bbfdcbbcf50ce0635d3f8f
160160
cache.h | 8 ++++----
@@ -168,10 +168,10 @@ Committed merge 7fb9b7262a1d1e0a47bbfdcbbcf50ce0635d3f8f
168168
And the final repository status looks like this:
169169

170170
------------------------------------------------
171-
$ git show-branch --more=1 master seen rc
172-
! [master] Revert "Replace zero-length array decls with []."
171+
$ git show-branch --more=1 main seen rc
172+
! [main] Revert "Replace zero-length array decls with []."
173173
! [seen] git-repack: Add option to repack all objects.
174-
* [rc] Merge refs/heads/master from .
174+
* [rc] Merge refs/heads/main from .
175175
---
176176
+ [seen] git-repack: Add option to repack all objects.
177177
+ [seen~1] More documentation updates.
@@ -180,8 +180,8 @@ $ git show-branch --more=1 master seen rc
180180
+ [seen~4] Document "git cherry-pick" and "git revert"
181181
+ [seen~5] Remove git-apply-patch-script.
182182
+ [seen~6] Redo "revert" using three-way merge machinery.
183-
- [rc] Merge refs/heads/master from .
184-
++* [master] Revert "Replace zero-length array decls with []."
185-
- [rc~1] Merge refs/heads/master from .
186-
... [master~1] Merge refs/heads/portable from http://www.cs.berkeley....
183+
- [rc] Merge refs/heads/main from .
184+
++* [main] Revert "Replace zero-length array decls with []."
185+
- [rc~1] Merge refs/heads/main from .
186+
... [main~1] Merge refs/heads/portable from http://www.cs.berkeley....
187187
------------------------------------------------

Documentation/howto/separating-topic-branches.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ than HEAD] while rewriting messy development history. For example, I
1414
start doing some work without knowing exactly where it leads, and end
1515
up with a history like this:
1616

17-
"master"
17+
"main"
1818
o---o
1919
\ "topic"
2020
o---o---o---o---o---o
@@ -25,35 +25,35 @@ And often, one topic component is larger than the other. It may
2525
contain more than two topics.
2626

2727
In order to rewrite this mess to be more manageable, I would first do
28-
"diff master..topic", to extract the changes into a single patch, start
28+
"diff main..topic", to extract the changes into a single patch, start
2929
picking pieces from it to get logically self-contained units, and
30-
start building on top of "master":
30+
start building on top of "main":
3131

32-
$ git diff master..topic >P.diff
33-
$ git checkout -b topicA master
32+
$ git diff main..topic >P.diff
33+
$ git checkout -b topicA main
3434
... pick and apply pieces from P.diff to build
3535
... commits on topicA branch.
3636

3737
o---o---o
3838
/ "topicA"
39-
o---o"master"
39+
o---o"main"
4040
\ "topic"
4141
o---o---o---o---o---o
4242

4343
Before doing each commit on "topicA" HEAD, I run "diff HEAD"
4444
before update-index the affected paths, or "diff --cached HEAD"
45-
after. Also I would run "diff --cached master" to make sure
45+
after. Also I would run "diff --cached main" to make sure
4646
that the changes are only the ones related to "topicA". Usually
4747
I do this for smaller topics first.
4848

4949
After that, I'd do the remainder of the original "topic", but
5050
for that, I do not start from the patchfile I extracted by
51-
comparing "master" and "topic" I used initially. Still on
51+
comparing "main" and "topic" I used initially. Still on
5252
"topicA", I extract "diff topic", and use it to rebuild the
5353
other topic:
5454

5555
$ git diff -R topic >P.diff ;# --cached also would work fine
56-
$ git checkout -b topicB master
56+
$ git checkout -b topicB main
5757
... pick and apply pieces from P.diff to build
5858
... commits on topicB branch.
5959

@@ -62,7 +62,7 @@ other topic:
6262
/
6363
/o---o---o
6464
|/ "topicA"
65-
o---o"master"
65+
o---o"main"
6666
\ "topic"
6767
o---o---o---o---o---o
6868

@@ -76,7 +76,7 @@ After I am done, I'd try a pretend-merge between "topicA" and
7676
/ /
7777
/o---o---o----------'
7878
|/ "topicA"
79-
o---o"master"
79+
o---o"main"
8080
\ "topic"
8181
o---o---o---o---o---o
8282

@@ -91,4 +91,4 @@ for cruft. Then I can finally clean things up:
9191
/
9292
/o---o---o
9393
|/ "topicA"
94-
o---o"master"
94+
o---o"main"

Documentation/howto/setup-git-server-over-http.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ To check whether all is OK, do:
214214

215215
curl --netrc --location -v http://<username>@<servername>/my-new-repo.git/HEAD
216216

217-
...this should give something like 'ref: refs/heads/master', which is
217+
...this should give something like 'ref: refs/heads/main', which is
218218
the content of the file HEAD on the server.
219219

220220
Now, add the remote in your existing repository which contains the project
@@ -233,9 +233,9 @@ Step 4: make the initial push
233233

234234
From your client repository, do
235235

236-
$ git push upload master
236+
$ git push upload main
237237

238-
This pushes branch 'master' (which is assumed to be the branch you
238+
This pushes branch 'main' (which is assumed to be the branch you
239239
want to export) to repository called 'upload', which we previously
240240
defined with git-config.
241241

Documentation/howto/update-hook-example.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ section of the documentation:
2121
$GIT_DIR/hooks/update refname sha1-old sha1-new
2222

2323
The refname parameter is relative to $GIT_DIR; e.g. for the
24-
master head this is "refs/heads/master". Two sha1 are the
24+
main head this is "refs/heads/main". Two sha1 are the
2525
object names for the refname before and after the update. Note
2626
that the hook is called before the refname is updated, so either
2727
sha1-old is 0{40} (meaning there is no such ref yet), or it
@@ -178,7 +178,7 @@ This uses two files, $GIT_DIR/info/allowed-users and
178178
allowed-groups, to describe which heads can be pushed into by
179179
whom. The format of each file would look like this:
180180

181-
refs/heads/master junio
181+
refs/heads/main junio
182182
+refs/heads/seen junio
183183
refs/heads/cogito$ pasky
184184
refs/heads/bw/.* linus
@@ -187,6 +187,6 @@ whom. The format of each file would look like this:
187187

188188
With this, Linus can push or create "bw/penguin" or "bw/zebra"
189189
or "bw/panda" branches, Pasky can do only "cogito", and JC can
190-
do master and "seen" branches and make versioned tags. And anybody
191-
can do tmp/blah branches. The '+' sign at the "seen" record means
190+
do main and seen branches and make versioned tags. And anybody
191+
can do tmp/blah branches. The '+' sign at the seen record means
192192
that JC can make non-fast-forward pushes on it.

Documentation/howto/using-merge-subtree.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ What you want is the 'subtree' merge strategy, which helps you in such a
2525
situation.
2626

2727
In this example, let's say you have the repository at `/path/to/B` (but
28-
it can be a URL as well, if you want). You want to merge the 'master'
28+
it can be a URL as well, if you want). You want to merge the 'main'
2929
branch of that repository to the `dir-B` subdirectory in your current
3030
branch.
3131

3232
Here is the command sequence you need:
3333

3434
----------------
3535
$ git remote add -f Bproject /path/to/B <1>
36-
$ git merge -s ours --no-commit --allow-unrelated-histories Bproject/master <2>
37-
$ git read-tree --prefix=dir-B/ -u Bproject/master <3>
36+
$ git merge -s ours --no-commit --allow-unrelated-histories Bproject/main <2>
37+
$ git read-tree --prefix=dir-B/ -u Bproject/main <3>
3838
$ git commit -m "Merge B project as our subdirectory" <4>
3939

40-
$ git pull -s subtree Bproject master <5>
40+
$ git pull -s subtree Bproject main <5>
4141
----------------
4242
<1> name the other project "Bproject", and fetch.
4343
<2> prepare for the later step to record the result as a merge.
44-
<3> read "master" branch of Bproject to the subdirectory "dir-B".
44+
<3> read "main" branch of Bproject to the subdirectory "dir-B".
4545
<4> record the merge result.
4646
<5> maintain the result with subsequent merges using "subtree"
4747

0 commit comments

Comments
 (0)