简体   繁体   中英

Proper way to submit pull request via GitHub (when contributing to open source)

I've forked and cloned a project from GitHub, then made a branch off master to make my changes. Once I've made changes and want to submit a pull request, and was wondering what would be the best way to do it.

(1) Submit a pull request to the upstream repo directly off of my branch, then merge my branch with master in my repo later on

or

(2) Merge my branch with master in my repo first, then submit a pull request to the upstream repo from my master?

As a rule of thumb, you should not develop on the master branch. Although you technically can, the master branch is usually used to track the current state of the project. Since your pull request was not accepted yet, it does not reflect the current state, and merging it to your local master will just cause confusion. The best practice would be something like this:

  1. Fork the project
  2. Create a local feature branch (eg, git checkout -b myfeature )
  3. Develop, test and validate locally.
  4. Push the local feature branch to a remote branch on your GitHub account (eg, git push origin myfeature ).
  5. Create a pull request from your feature branch ( yourname/myfeature ) to the master branch ( projectowner/master ).
  6. Get reviewed, fix pull request as needed
  7. Project maintainer merges your pull request
  8. Update your own local master with the merged patch (eg, git fetch upstream && git rebase upstream/master ).

(1) is better because you can have multiple branches - one branch per pull request. And you do not need to merge a PR branch to master (unless you want to).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM