简体   繁体   中英

GitHub better way to work with multi pull requests?

I have been working with an open source project which requires to push all pull requests (PR) into the master branch. All PRs won't be merged until releasing a new version. Suppose I have pushed a PR and want to work with a new one. I need to remove all codes of the previous one. I can't create a new branch since the project requirements. However, if I do anything with those code and push to my fork, it will reflect immediately to my previous PR. To avoid affecting, I have to delete my current fork first, fork again for the new PR. It works for me but needed many steps, quite frustrating and hard to be back to work with previous PRs.

Any better way? Thanks

There might be a misunderstanding of the process. You should open a pull request to merge a branch into master. The branch you are merging from should not be master. It should be a topic branch. Remember that merging requires two branches: the source branch and the destination branch.

In the case of a pull request the destination branch is master. The source branch should not be master in your fork. It should be a topic branch in your fork.

The proper flow is:

  1. Pull the latest from the original repository's master branch into the master branch in your fork

    # Configure remote from where you forked your repo (do this only once) git remote add upstream https://github.com/foo/bar.git # Do these steps before starting on a new feature git fetch upstream git checkout master git merge upstream/master git push origin HEAD
  2. Create a topic branch off of master on your fork
    git checkout -b feature master
  3. Do work and commit as often as you like
    git commit -m "..."
  4. Push your topic branch to your fork on GitHub
     git push origin -u HEAD
  5. Submit pull request on the original repository to merge the topic branch in your fork into the master branch on their repository

Repeat steps 1-5 for as many pull requests as you deem necessary.

It should be obvious by the history in the pull request whether or not your topic branch is up to date. If their repository requires you to merge your master into their master for a pull request, their process is broken. They are doing it wrong, and for the very reason you are asking a question on StackOverflow.

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