Skip to content

Commit 0afbf6b

Browse files
authored
improve instructions about merging git branches in the step-by-step guide
1 parent 3ff86ce commit 0afbf6b

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

pullrequest.rst

+47-6
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ You should have already :ref:`set up your system <setup>`,
9494

9595
git push origin <branch-name>
9696

97-
* If someone else added new changesets and you get an error::
98-
99-
git fetch upstream
100-
git merge upstream/master
101-
git push origin <branch-name>
102-
10397
* Finally go on :samp:`https://github.com/{<your-username>}/cpython`: you will
10498
see a box with the branch you just pushed and a green button that allows
10599
you to create a pull request against the official CPython repository.
@@ -114,6 +108,24 @@ You should have already :ref:`set up your system <setup>`,
114108
git commit -m '<message>'
115109
git push origin <branch-name>
116110

111+
* If a core developer reviewing your PR pushed one or more commits to your
112+
PR branch, then after checking out your branch and before editing, run::
113+
114+
git pull origin <branch-name> # pull = fetch + merge
115+
116+
If you have made local changes that have not been pushed to your fork and
117+
there are merge conflicts, git will warn you about this and enter conflict
118+
resolution mode. See :ref:`resolving-merge-conflicts` below.
119+
120+
* If time passes and there are merge conflicts with the master branch, GitHub
121+
will show a warning to this end and you may be asked to address this. Merge
122+
the changes from the master branch while resolving the conflicts locally::
123+
124+
git checkout <branch-name>
125+
git pull upstream master # pull = fetch + merge
126+
# resolve conflicts: see "Resolving Merge Conflicts" below
127+
git push origin <branch-name>
128+
117129
* After your PR has been accepted and merged, you can :ref:`delete the branch
118130
<deleting_branches>`::
119131

@@ -125,6 +137,35 @@ You should have already :ref:`set up your system <setup>`,
125137
workflow is **strongly** preferred.
126138

127139

140+
.. _resolving-merge-conflicts:
141+
142+
Resolving Merge Conflicts
143+
'''''''''''''''''''''''''
144+
145+
When merging changes from different branches (or variants of a branch on
146+
different repos), the two branches may contain incompatible changes to one
147+
or more files. These are called "merge conflicts" and need to be manually
148+
resolved as follows:
149+
150+
#. Check which files have merge conflicts::
151+
152+
git status
153+
154+
#. Edit the affected files and bring them to their intended final state.
155+
Make sure to remove the special "conflict markers" inserted by git.
156+
157+
#. Commit the affected files::
158+
159+
git add <filenames>
160+
git merge --continue
161+
162+
When running the final command, git may open an editor for writing a commit
163+
message. It is usually okay to leave that as-is and close the editor.
164+
165+
See `the merge command's documentation <https://git-scm.com/docs/git-merge>`_
166+
for a detailed technical explanation.
167+
168+
128169
.. _good-prs:
129170

130171
Making Good PRs

0 commit comments

Comments
 (0)