8000 Improve gitbootcamp (#524) · python/devguide@2a78cb5 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 2a78cb5

Browse files
geryogamaeroseamanu
authored andcommitted
Improve gitbootcamp (#524)
Co-Authored-By: Kyle Stanley <aeros167@gmail.com> Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com>
1 parent 6460040 commit 2a78cb5

File tree

1 file changed

+40
-51
lines changed

1 file changed

+40
-51
lines changed

gitbootcamp.rst

Lines changed: 40 additions & 51 deletions
249
Original file line numberDiff line numberDiff line change
@@ -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
2222
relevant to CPython's workflow.
2323

2424
.. note::
@@ -33,26 +33,26 @@ relevant to CPython's workflow.
3333
Forking CPython GitHub Repository
3434
---------------------------------
3535

36-
You'll only need to do this once.
36+
You will only need to do this once.
3737

3838
1. Go to https://github.com/python/cpython.
3939

4040
2. Press ``Fork`` on the top right.
4141

4242
3. 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,
7070
and ``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

9393
Enabling ``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.
9797
This should be enabled on Windows, since the public repository has a hook which
9898
will reject all changesets having the wrong line endings::
9999

@@ -112,7 +112,7 @@ Create a new branch and switch to it::
112112

113113
This 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

143142
Deleting Branches
@@ -154,7 +153,6 @@ To delete a **remote** branch::
154153

155154
You may specify more than one branch for deletion.
156155

157-
158156
Staging and Committing Files
159157
----------------------------
160158

@@ -164,28 +162,26 @@ Staging and Committing Files
164162

165163
2. 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

169167
3. 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

179176
To revert changes to a file that has not been committed yet::
180177

181-
git checkout path/to/file
178+
git checkout <filename>
182179

183180
If the change has been committed, and now you want to reset it to whatever
184181
the origin is at::
185182

186183
git reset --hard HEAD
187184

188-
189185
Stashing 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

F438
218213
Pushing 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
222217
them to the remote repository.
223218

224219
::
225220

226221
git checkout <branch-name>
227222
git push origin <branch-name>
228223

229-
230224
Creating a Pull Request
231225
-----------------------
232226

233227
1. 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

250243
Scenario:
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.
256
- You now want to update your forked CPython repository to be the same as
257-
upstream.
250+
the upstream CPython repository.
258251

259252
Solution::
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

273267
Solution::
274268

@@ -282,9 +276,8 @@ you run ``git merge upstream/master``.
282276

283277
When 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

327320
6. Push the changes and open a pull request.
328321

329-
330-
331322
.. _git_pr:
332323

333324
Downloading 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

371361
Pull 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

405394
Backporting Merged Changes
406395
--------------------------
@@ -418,7 +407,7 @@ The commit hash for backporting is the squashed commit that was merged to
418407
the ``master`` branch. On the merged pull request, scroll to the bottom of the
419408
page. 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

423412
By following the link to ``<commit_sha1>``, you will get the full commit hash.
424413

@@ -466,15 +455,15 @@ items like updating ``Misc/ACKS``.
466455
To edit an open pull request that targets ``master``:
467456

468457
1. 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

473462
2. 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

479468
3. 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

494483
5. Optionally, :ref:`delete the PR branch <deleting_branches>`.

0 commit comments

Comments
 (0)
0