Can I create a pull request using the same branch as the base and compare branch?

22,528

Solution 1

If the PR will be issued from the same github repo, then it has to be done via branching, i.e. create a branch off of a known branch and make changes, then create PR by comparing the two branches. Thanks to everyone who helped confirm this.

If someone makes a fork of a github repo, then changes in the forked repo can be used to issue PR based on seemingly same branch (in two different repos, i.e. one original, the other the fork). This is where I was confused because I saw the PR came from seemingly the same branch, but actually, it is from a different repo (a fork), technically.

Solution 2

The phrases "do all of the pull request on the branch alone" and "not involving master" does not really make sense, because a pull request is basically a set of changes that are requested to be merged into a branch, which in your case would be the master branch.

Here is a description from GitHub's page on pull requests:

Pull requests let you tell others about changes you've pushed to a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before the changes are merged into the repository.
...
After initializing a pull request, you'll see a review page that shows a high-level overview of the changes between your branch (the compare branch) and the repository's base branch.

In addition, creating a pull request will require you to specify the branch you want to merge the changes into, which in your case, would be the master branch.

If you're intent on never involving the master branch, you can create a patch instead for the commits relating to the bug fixes, then perform the code review there. (You can also create a patch by diff-ing the modified files). But that will just make code review more difficult.

Solution 3

Pull requests are simply tell github that i want this branch to take this commits only after it has been reviewed and approved.

When doing a pull request, it involves two branches 1. The comparing branch (The one you're pushing) 2. The base branch (The one to review changes after approval)

The base branch is usually master, but not limited to master.

Simply change it to the branch you want to merge the PR into and you're done!

Pull requests is not meant for master alone!

Share:
22,528
For Comment
Author by

For Comment

Updated on August 24, 2020

Comments

  • For Comment
    For Comment over 3 years

    I have a github repo that has master and a branch. We have been developing on branch and then every time we push out a release, we merge the branch's changes into master, then start the next phase of development on branch again. Now, we are asked to use pull request for bug fixes on branch. So the question is, how to do all of the pull request on the branch alone, not involving the master?

    More specifically, I have branchA that has a bugfix change, then I commit and push to the branchA repo, then I go to my github repo webpage and try to do a pull request by specifying both the base branch and the compare branch as 'branchA', then github says: There isn’t anything to compare. You’ll need to use two different branch names to get a valid comparison. This definitely makes sense, so I am asking if it is possible to somehow compare the SAME branch before and after bug fix via a pull request.