@@ -18,7 +18,7 @@ Git Bootcamp and Cheat Sheet
1818 desire a different approach.
1919
2020
21- In this section, we'll go over some commonly used Git commands that are
21+ In this section, we will go over some commonly used Git commands that are
2222relevant to CPython's workflow.
2323
2424.. note ::
@@ -33,26 +33,26 @@ relevant to CPython's workflow.
3333Forking CPython GitHub Repository
3434---------------------------------
3535
36- You'll only need to do this once.
36+ You will only need to do this once.
3737
38381. Go to https://github.com/python/cpython.
3939
40402. Press ``Fork `` on the top right.
4141
42423. When asked where to fork the repository, choose to fork it to your username.
4343
44- 4. Your fork will be created at https://github.com/<username>/cpython.
44+ 4. Your forked CPython repository will be created at https://github.com/<username>/cpython.
4545
4646.. _clone-your-fork :
4747
48- Cloning The Forked CPython Repository
49- -------------------------------------
48+ Cloning a Forked CPython Repository
49+ -----------------------------------
5050
51- You'll only need to do this once. From your command line::
51+ You will only need to do this once. From your command line::
5252
5353 git clone git@github.com:<username>/cpython.git
5454
55- It is also recommended to configure an ``upstream `` remote::
55+ It is also recommended to configure an ``upstream `` remote repository ::
5656
5757 cd cpython
5858 git remote add upstream git@github.com:python/cpython.git
@@ -66,11 +66,11 @@ To list the remote repositories that are configured, along with their URLs::
6666
6767 git remote -v
6868
69- You should have two remotes : ``origin `` pointing to your fork ,
69+ You should have two remote repositories : ``origin `` pointing to your forked CPython repository ,
7070and ``upstream `` pointing to the official CPython repository::
7171
72- origin git@github.com:<your- username>/cpython.git (fetch)
73- origin git@github.com:<your- username>/cpython.git (push)
72+ origin git@github.com:<username>/cpython.git (fetch)
73+ origin git@github.com:<username>/cpython.git (push)
7474 upstream git@github.com:python/cpython.git (fetch)
7575 upstream git@github.com:python/cpython.git (push)
7676
@@ -83,17 +83,17 @@ Setting Up Your Name and Email Address
8383.. code-block :: bash
8484
8585 git config --global user.name " Your Name"
86- git config --global user.email email@example.org
86+ git config --global user.email your. email@example.com
8787
88- The ``--global `` flag sets these globally,
89- ``--local `` sets them only for the current project.
88+ The ``--global `` flag sets these parameters globally while
89+ the ``--local `` flag sets them only for the current project.
9090
9191.. _autocrlf :
9292
9393Enabling ``autocrlf `` on Windows
9494--------------------------------
9595
96- The * autocrlf * option will fix automatically any Windows-specific line endings.
96+ The `` autocrlf `` option will fix automatically any Windows-specific line endings.
9797This should be enabled on Windows, since the public repository has a hook which
9898will reject all changesets having the wrong line endings::
9999
@@ -112,7 +112,7 @@ Create a new branch and switch to it::
112112
113113This is equivalent to::
114114
115- # create a new branch off ' master' , without checking it out
115+ # create a new branch from master, without checking it out
116116 git branch <branch-name> master
117117 # check out the branch
118118 git checkout <branch-name>
@@ -137,7 +137,6 @@ on the 2.7 release from the ``upstream`` remote::
137137
138138 git checkout -b 2.7 upstream/2.7
139139
140-
141140.. _deleting_branches :
142141
143142Deleting Branches
@@ -154,7 +153,6 @@ To delete a **remote** branch::
154153
155154You may specify more than one branch for deletion.
156155
157-
158156Staging and Committing Files
159157----------------------------
160158
@@ -164,28 +162,26 @@ Staging and Committing Files
164162
1651632. To stage the files to be included in your commit::
166164
167- git add path/to/file1 path/to/file2 path/to/file3
165+ git add <filename1> <filename2>
168166
1691673. To commit the files that have been staged (done in step 2):
170168
171169 .. code-block :: bash
172170
173171 git commit -m " bpo-XXXX: This is the commit message."
174172
175-
176173 Reverting Changes
177174-----------------
178175
179176To revert changes to a file that has not been committed yet::
180177
181- git checkout path/to/file
178+ git checkout <filename>
182179
183180If the change has been committed, and now you want to reset it to whatever
184181the origin is at::
185182
186183 git reset --hard HEAD
187184
188-
189185Stashing Changes
190186----------------
191187
@@ -210,51 +206,48 @@ Commit the files:
210206
211207.. code-block :: bash
212208
213- git commit -m ' <message>'
214-
209+ git commit -m " <message>"
215210
216211 .. _push-changes :
217212
218213Pushing Changes
219214---------------
220215
221- Once your changes are ready for a review or a pull request, you'll need to push
216+ Once your changes are ready for a review or a pull request, you will need to push
222217them to the remote repository.
223218
224219::
225220
226221 git checkout <branch-name>
227222 git push origin <branch-name>
228223
229-
230224Creating a Pull Request
231225-----------------------
232226
2332271. Go to https://github.com/python/cpython.
234228
235- 2. Press ``New pull request `` button.
229+ 2. Press the ``New pull request `` button.
236230
237- 3. Click ``compare across forks `` link.
231+ 3. Click the ``compare across forks `` link.
238232
239- 4. Select the base fork : ``python/cpython `` and base branch: ``master ``.
233+ 4. Select the base repository : ``python/cpython `` and base branch: ``master ``.
240234
241- 5. Select the head fork : ``<username>/cpython `` and base branch: the branch
235+ 5. Select the head repository : ``<username>/cpython `` and head branch: the branch
242236 containing your changes.
243237
244- 6. Press ``Create Pull Request `` button.
238+ 6. Press the ``Create pull request `` button.
245239
246-
247- Syncing With Upstream
240+ Syncing with Upstream
248241---------------------
249242
250243Scenario:
251244
252245- You forked the CPython repository some time ago.
253246- Time passes.
254- - There have been new commits made in upstream CPython repository.
247+ - There have been new commits made in the upstream CPython repository.
255248- Your forked CPython repository is no longer up to date.
256249- You now want to update your forked CPython repository to be the same as
257- upstream.
250+ the upstream CPython repository .
258251
259252Solution::
260253
@@ -267,8 +260,9 @@ Another scenario:
267260- You created ``some-branch `` some time ago.
268261- Time passes.
269262- You made some commits to ``some-branch ``.
270- - Meanwhile, there are recent changes from upstream CPython repository.
271- - You want to incorporate the recent changes from upstream into ``some-branch ``.
263+ - Meanwhile, there are recent changes from the upstream CPython repository.
264+ - You want to incorporate the recent changes from the upstream CPython
265+ repository into ``some-branch ``.
272266
273267Solution::
274268
@@ -282,9 +276,8 @@ you run ``git merge upstream/master``.
282276
283277When it happens, you need to resolve conflict. See these articles about resolving conflicts:
284278
285- * `About merge conflicts <https://help.github.com/en/articles/about-merge-conflicts >`_
286- * `Resolving a merge conflict using the command line <https://help.github.com/en/articles/resolving-a-merge-conflict-using-the-command-line >`_
287-
279+ - `About merge conflicts <https://help.github.com/en/articles/about-merge-conflicts >`_
280+ - `Resolving a merge conflict using the command line <https://help.github.com/en/articles/resolving-a-merge-conflict-using-the-command-line >`_
288281
289282.. _git_from_mercurial :
290283
@@ -326,8 +319,6 @@ Solution:
326319
3273206. Push the changes and open a pull request.
328321
329-
330-
331322.. _git_pr :
332323
333324Downloading Other's Patches
@@ -342,7 +333,7 @@ On Unix and MacOS, set up the following git alias::
342333
343334 $ git config --global alias.pr '!sh -c "git fetch upstream pull/${1}/head:pr_${1} && git checkout pr_${1}" -'
344335
345- On Windows, reverse the single (`' ` ) and double (`" `) quotes:
336+ On Windows, reverse the single (`` ' `` ) and double (`` " ` `) quotes:
346337
347338.. code-block :: bash
348339
@@ -362,10 +353,9 @@ local copy of a pull request as follows::
362353 So you can ``git push `` if the pull request author checked
363354 "Allow edits from maintainers" when creating the pull request.
364355
365-
366356.. _accepting-and-merging-a-pr :
367357
368- Accepting and Merging A Pull Request
358+ Accepting and Merging a Pull Request
369359------------------------------------
370360
371361Pull requests can be accepted and merged by a Python Core Developer.
@@ -399,8 +389,7 @@ Pull requests can be accepted and merged by a Python Core Developer.
399389 `How to Write a Git Commit Message <https://chris.beams.io/posts/git-commit/ >`_
400390 is a nice article describing how to write a good commit message.
401391
402- 3. Press the ``Confirm squash and merge `` button.
403-
392+ 4. Press the ``Confirm squash and merge `` button.
404393
405394Backporting Merged Changes
406395--------------------------
@@ -418,7 +407,7 @@ The commit hash for backporting is the squashed commit that was merged to
418407the ``master `` branch. On the merged pull request, scroll to the bottom of the
419408page. Find the event that says something like::
420409
421- <coredeveloper > merged commit <commit_sha1> into python:master <sometime> ago.
410+ <core_developer > merged commit <commit_sha1> into python:master <sometime> ago.
422411
423412By following the link to ``<commit_sha1> ``, you will get the full commit hash.
424413
@@ -466,15 +455,15 @@ items like updating ``Misc/ACKS``.
466455To edit an open pull request that targets ``master ``:
467456
4684571. In the pull request page, under the description, there is some information
469- about the contributor's fork and branch name that will be useful later::
458+ about the contributor's forked CPython repository and branch name that will be useful later::
470459
471460 <contributor> wants to merge 1 commit into python:master from <contributor>:<branch_name>
472461
4734622. Fetch the pull request, using the :ref: `git pr <git_pr >` alias::
474463
475464 git pr <pr_number>
476465
477- This will checkout the contributor's branch at ``pr_XXX ``.
466+ This will checkout the contributor's branch at ``<pr_number> ``.
478467
4794683. Make and commit your changes on the branch. For example, merge in changes
480469 made to ``master `` since the PR was submitted (any merge commits will be
@@ -485,10 +474,10 @@ To edit an open pull request that targets ``master``:
485474 git fetch upstream
486475 git merge upstream/master
487476 git add < filename>
488- git commit -m " <commit message>"
477+ git commit -m " <message>"
489478
490479 4. Push the changes back to the contributor's PR branch::
491480
492- git push git@github.com:<contributor>/cpython <pr_XXX >:<branch_name>
481+ git push git@github.com:<contributor>/cpython <pr_number >:<branch_name>
493482
4944835. Optionally, :ref: `delete the PR branch <deleting_branches >`.
0 commit comments