@@ -103,17 +103,17 @@ Creating and Switching Branches
103
103
-------------------------------
104
104
105
105
.. important ::
106
- Never commit directly to the ``master `` branch.
106
+ Never commit directly to the ``main `` branch.
107
107
108
108
Create a new branch and switch to it::
109
109
110
- # creates a new branch off master and switch to it
111
- git checkout -b <branch-name> master
110
+ # creates a new branch off main and switch to it
111
+ git checkout -b <branch-name> main
112
112
113
113
This is equivalent to::
114
114
115
- # create a new branch from master , without checking it out
116
- git branch <branch-name> master
115
+ # create a new branch from main , without checking it out
116
+ git branch <branch-name> main
117
117
# check out the branch
118
118
git checkout <branch-name>
119
119
@@ -144,7 +144,7 @@ Deleting Branches
144
144
145
145
To delete a **local ** branch that you no longer need::
146
146
147
- git checkout master
147
+ git checkout main
148
148
git branch -D <branch-name>
149
149
150
150
To delete a **remote ** branch::
@@ -153,6 +153,19 @@ To delete a **remote** branch::
153
153
154
154
You may specify more than one branch for deletion.
155
155
156
+
157
+ Renaming Branch
158
+ ---------------
159
+
160
+ The CPython repository's default branch was renamed from ``master `` to ``main ``
161
+ after the Python 3.10b1 release. If you had cloned the repository before this
162
+ change, you can rename your local branch as follows::
163
+
164
+ git branch -m master main
165
+ git fetch upstream
166
+ git branch -u upstream/main main
167
+
168
+
156
169
Staging and Committing Files
157
170
----------------------------
158
171
@@ -230,7 +243,7 @@ Creating a Pull Request
230
243
231
244
3. Click the ``compare across forks `` link.
232
245
233
- 4. Select the base repository: ``python/cpython `` and base branch: ``master ``.
246
+ 4. Select the base repository: ``python/cpython `` and base branch: ``main ``.
234
247
235
248
5. Select the head repository: ``<username>/cpython `` and head branch: the branch
236
249
containing your changes.
@@ -250,14 +263,14 @@ Scenario:
250
263
the upstream CPython repository.
251
264
252
265
Please do not try to solve this by creating a pull request from
253
- ``python:master `` to ``<username>:master `` as the authors of the patches will
266
+ ``python:main `` to ``<username>:main `` as the authors of the patches will
254
267
get notified unnecessarily.
255
268
256
269
Solution::
257
270
258
- git checkout master
259
- git pull upstream master
260
- git push origin master
271
+ git checkout main
272
+ git pull upstream main
273
+ git push origin main
261
274
262
275
.. note :: For the above commands to work, please follow the instructions found
263
276
in the :ref: `checkout ` section
@@ -275,11 +288,11 @@ Solution::
275
288
276
289
git checkout some-branch
277
290
git fetch upstream
278
- git merge upstream/master
291
+ git merge upstream/main
279
292
git push origin some-branch
280
293
281
294
You may see error messages like "CONFLICT" and "Automatic merge failed;" when
282
- you run ``git merge upstream/master ``.
295
+ you run ``git merge upstream/main ``.
283
296
284
297
When it happens, you need to resolve conflict. See these articles about resolving conflicts:
285
298
@@ -308,7 +321,7 @@ Solution:
308
321
309
322
.. code-block:: bash
310
323
311
- git checkout $(git rev-list -n 1 --before="yyyy-mm-dd hh:mm:ss" master )
324
+ git checkout $(git rev-list -n 1 --before="yyyy-mm-dd hh:mm:ss" main )
312
325
git apply /path/to/issueNNNN-git.patch
313
326
314
327
If the patch still won't apply, then a patch tool will not be able to
@@ -321,7 +334,7 @@ Solution:
321
334
5. If the patch was applied to an old revision, it needs to be updated and
322
335
merge conflicts need to be resolved::
323
336
324
- git rebase master
337
+ git rebase main
325
338
git mergetool
326
339
327
340
6. Push the changes and open a pull request.
@@ -388,7 +401,7 @@ Pull requests can be accepted and merged by a Python Core Developer.
388
401
bpo-12345: Improve the spam module (#777)
389
402
390
403
* Improve the spam module
391
- * merge from master
404
+ * merge from main
392
405
* adjust code based on review comment
393
406
* rebased
394
407
@@ -402,7 +415,7 @@ Backporting Merged Changes
402
415
--------------------------
403
416
404
417
A pull request may need to be backported into one of the maintenance branches
405
- after it has been accepted and merged into ``master ``. It is usually indicated
418
+ after it has been accepted and merged into ``main ``. It is usually indicated
406
419
by the label ``needs backport to X.Y `` on the pull request itself.
407
420
408
421
Use the utility script
@@ -411,10 +424,10 @@ from the `core-workflow <https://github.com/python/core-workflow>`_
411
424
repository to backport the commit.
412
425
413
426
The commit hash for backporting is the squashed commit that was merged to
414
- the ``master `` branch. On the merged pull request, scroll to the bottom of the
427
+ the ``main `` branch. On the merged pull request, scroll to the bottom of the
415
428
page. Find the event that says something like::
416
429
417
- <core_developer> merged commit <commit_sha1> into python:master <sometime> ago.
430
+ <core_developer> merged commit <commit_sha1> into python:main <sometime> ago.
418
431
419
432
By following the link to ``<commit_sha1> ``, you will get the full commit hash.
420
433
@@ -459,12 +472,12 @@ items like updating ``Misc/ACKS``.
459
472
460
473
.. _Allow edits from maintainers : https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/
461
474
462
- To edit an open pull request that targets ``master ``:
475
+ To edit an open pull request that targets ``main ``:
463
476
464
477
1. In the pull request page, under the description, there is some information
465
478
about the contributor's forked CPython repository and branch name that will be useful later::
466
479
467
- <contributor> wants to merge 1 commit into python:master from <contributor>:<branch_name>
480
+ <contributor> wants to merge 1 commit into python:main from <contributor>:<branch_name>
468
481
469
482
2. Fetch the pull request, using the :ref: `git pr <git_pr >` alias::
470
483
@@ -473,13 +486,13 @@ To edit an open pull request that targets ``master``:
473
486
This will checkout the contributor's branch at ``<pr_number>``.
474
487
475
488
3. Make and commit your changes on the branch. For example, merge in changes
476
- made to ``master `` since the PR was submitted (any merge commits will be
489
+ made to ``main `` since the PR was submitted (any merge commits will be
477
490
removed by the later ``Squash and Merge `` when accepting the change):
478
491
479
492
.. code-block :: bash
480
493
481
494
git fetch upstream
482
- git merge upstream/master
495
+ git merge upstream/main
483
496
git add < filename>
484
497
git commit -m " <message>"
485
498
0 commit comments