Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 247
For Comment Avatar asked Aug 18 '17 23:08

For Comment


People also ask

Can we create two pull requests from same branch?

There can be only one open PR from a given branch.

Does a pull request need a new branch?

Pull requests can be used in conjunction with the Feature Branch Workflow, the Gitflow Workflow, or the Forking Workflow. But a pull request requires either two distinct branches or two distinct repositories, so they will not work with the Centralized Workflow.

How do I create a pull request for the same branch in GitHub?

Click Create Pull Request. GitHub Desktop will open your default browser to take you to GitHub. On GitHub, confirm that the branch in the base: drop-down menu is the branch where you want to merge your changes. Confirm that the branch in the compare: drop-down menu is the topic branch where you made your changes.


2 Answers

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.

like image 67
For Comment Avatar answered Sep 21 '22 10:09

For Comment


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.

like image 34
Gino Mempin Avatar answered Sep 20 '22 10:09

Gino Mempin