Skip to content

Commit

Permalink
Prefer upstream for main (#943)
Browse files Browse the repository at this point in the history
* Update docs to configure 'main' to pull from 'upstream'. Ref python/core-workflow#475.

* Quote 'main'.

Co-authored-by: Ezio Melotti <[email protected]>

* Direct 'upstream' push to the user's fork. Now pull comes from upstream and push goes to origin.

* Apply the changes also to the git boot camp.

* Prefer https for upstream fetch.

Co-authored-by: C.A.M. Gerlach <[email protected]>

* Update expectations and sync guidance for d7e9065. Remove superfluous .git from https.

Co-authored-by: Ezio Melotti <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
  • Loading branch information
3 people authored Oct 30, 2022
1 parent c4fbdc9 commit 5e52f93
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
27 changes: 23 additions & 4 deletions getting-started/git-boot-camp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,29 @@ You will only need to do this once.
Cloning a Forked CPython Repository
-----------------------------------

You will only need to do this once. From your command line::
You will only need to do this once per machine. From your command line::

git clone [email protected]:<username>/cpython.git

It is also recommended to configure an ``upstream`` remote repository::

cd cpython
git remote add upstream git@github.com:python/cpython.git
git remote add upstream https://github.com/python/cpython

You can also use SSH-based or HTTPS-based URLs.

Configure the Remotes
---------------------

Configure ``git`` to pull ``main`` from the ``upstream`` remote::

git config --local branch.main.remote upstream

Since one should never attempt to push to ``upstream``, configure
``git`` to push always to ``origin``::

git remote set-url --push upstream [email protected]:<username>/cpython.git

Listing the Remote Repositories
-------------------------------

Expand All @@ -70,8 +82,15 @@ and ``upstream`` pointing to the official CPython repository::

origin [email protected]:<username>/cpython.git (fetch)
origin [email protected]:<username>/cpython.git (push)
upstream [email protected]:python/cpython.git (fetch)
upstream [email protected]:python/cpython.git (push)
upstream https://github.com/python/cpython (fetch)
upstream [email protected]:<username>/cpython.git (push)

To verify the upstream for ``main``::

git config branch.main.remote

It should emit ``upstream``, indicating to track/pull changes for ``main`` from the
``upstream`` remote.


.. _set-up-name-email:
Expand Down
21 changes: 16 additions & 5 deletions getting-started/setup-building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The CPython repo is hosted on GitHub. To get a copy of the source code you shoul
:ref:`fork the Python repository on GitHub <fork-cpython>`, :ref:`create a local
clone of your personal fork, and configure the remotes <clone-your-fork>`.

You will only need to execute these steps once:
You will only need to execute these steps once per machine:

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

Expand All @@ -79,15 +79,26 @@ You will only need to execute these steps once:
6. Configure an ``upstream`` remote::

$ cd cpython
$ git remote add upstream git@github.com:python/cpython.git
$ git remote add upstream https://github.com/python/cpython

7. Verify that your setup is correct::
7. Configure ``git`` to pull ``main`` from the ``upstream`` remote::

$ git config --local branch.main.remote upstream

8. Since one should never attempt to push to ``upstream``, configure
``git`` to push always to ``origin``::

$ git remote set-url --push upstream [email protected]:<your-username>/cpython.git

9. Verify that your setup is correct::

$ git remote -v
origin [email protected]:<your-username>/cpython.git (fetch)
origin [email protected]:<your-username>/cpython.git (push)
upstream [email protected]:python/cpython.git (fetch)
upstream [email protected]:python/cpython.git (push)
upstream https://github.com/python/cpython (fetch)
upstream [email protected]:<your-username>/cpython.git (push)
$ git config branch.main.remote
upstream

If you did everything correctly, you should now have a copy of the code
in the ``cpython`` directory and two remotes that refer to your own GitHub fork
Expand Down

0 comments on commit 5e52f93

Please sign in to comment.