Reputation: 1611
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
Upvotes: 0
Views: 152
Reputation: 18783
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:
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
git checkout -b feature master
git commit -m "..."
git push origin -u HEAD
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.
Upvotes: 1