Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing git command in pull request step-by-step guide #509

Closed
zthompson47 opened this issue Jul 16, 2019 · 2 comments · Fixed by #510
Closed

Missing git command in pull request step-by-step guide #509

zthompson47 opened this issue Jul 16, 2019 · 2 comments · Fixed by #510

Comments

@zthompson47
Copy link
Contributor

Hello,

I was following the pull request (PR) step-by-step guide from #103 and ran into an error with a git command. My PR has to do with a typo I found in the cpython documentation, and here are the steps to recreate the situation:

  1. Begin at https://devguide.python.org/docquality/#helping-with-documentation-issues
  2. Click "Quick Guide to Pull Requests" link
  3. Click "got the source code" link
  4. Follow instructions to fork, clone, and add upstream for cpython.git
(/tmp)$ git clone git@github.com:zthompson47/cpython.git
Cloning into 'cpython'...
remote: Enumerating objects: 757754, done.
remote: Total 757754 (delta 0), reused 0 (delta 0), pack-reused 757754
Receiving objects: 100% (757754/757754), 284.00 MiB | 2.60 MiB/s, done.
Resolving deltas: 100% (608403/608403), done.
Checking out files: 100% (4307/4307), done.
(/tmp)$ cd cpython 
(/tmp/cpython)$ git remote add upstream git@github.com:python/cpython.git
(/tmp/cpython)$ git remote -v
origin  git@github.com:zthompson47/cpython.git (fetch)
origin  git@github.com:zthompson47/cpython.git (push)
upstream        git@github.com:python/cpython.git (fetch)
upstream        git@github.com:python/cpython.git (push)
  1. Go back to https://devguide.python.org/pullrequest/#step-by-step-guide
  2. Try to "Create a new branch in your local clone"
(/tmp/cpython)$ git checkout -b new-local-branch upstream/master
fatal: 'upstream/master' is not a commit and a branch 'new-local-branch' cannot be created from it

I fixed the error by running git fetch upstream and repeating step six from above to create the branch. I'm no git expert, but I think the "Create a new branch in your local clone" could also just be git checkout -b <branch-name> as the upstream/master and local master branches should refer to the same commit at this point in the process.

I'm happy to submit a PR if warranted.

@methane
Copy link
Member

methane commented Jul 16, 2019

Nice catch. Please add git fetch upstream before git checkout -b <branch-name> upstream/master.

but I think the "Create a new branch in your local clone" could also just be git checkout -b <branch-name> as the upstream/master and local master branches should refer to the same commit at this point in the process.

Please note that people may start from an existing local clone, instead of fresh git clone.
Their local master branch may be old. Or it may contain local changes by the user.
upstream/master is much safer than master.

@zthompson47
Copy link
Contributor Author

Good point, and thanks for the quick feedback. I'll submit a PR later today.

willingc pushed a commit that referenced this issue Jul 22, 2019
* Add missing git command to pull request guide

The pull request step-by-step guide provides instructions to create a
git branch using upstream/master as the start-point.  This commit adds
a command to the guide which safely makes sure that this start-point
exists in the local repository.  Fixes #509.

* Clarify the need to configure git remote

This added comment explains the need for an existing remote to create a branch from.  The prerequisite git workflow is already documented.

Co-Authored-By: Kyle Stanley <aeros167@gmail.com>

* Move extra git step to its own bullet point
AA-Turner pushed a commit to AA-Turner/devguide that referenced this issue Jun 17, 2022
* Add missing git command to pull request guide

The pull request step-by-step guide provides instructions to create a
git branch using upstream/master as the start-point.  This commit adds
a command to the guide which safely makes sure that this start-point
exists in the local repository.  Fixes python#509.

* Clarify the need to configure git remote

This added comment explains the need for an existing remote to create a branch from.  The prerequisite git workflow is already documented.

Co-Authored-By: Kyle Stanley <aeros167@gmail.com>

* Move extra git step to its own bullet point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants