Github pull request of a branch - github

I have forked a master from upstream. I have created a branch, made some commits, and now want to issue a pull request. I want to know when my branch is merged by the user, will it get merged to the upstream master, or the user will have an option to create a new branch and merge my branch with it? Btw, I don't have push permission.

Where the Pull Request merges depends on how you create it, when you pick four things:
The base fork: Which fork of the repository the PR will be merged into
The base branch: Which branch in that repository the PR will be merged into
The compare fork: The fork with thew new code
The compare branch: The branch containing the new code
So if you configure the base to be upstream_repo:master, yes, when the PR is accepted, it will be merged to master.
For more, see GitHub's help on Using Pull Requests.

Related

New Pull Request when a previous one is pending Merge

I made some changes to several files of the project on a new branch (let's call it branch_a), I commited them, created the Pull Request, and it was recently reviewed and approved. It's still pending Merge on the master branch.
Now, someone asked for another change. It's a small supplemental change in 1 of the files edited in the first Pull Request.
What's the best way of doing this? Should I ask for the first Pull request to be merged and then create a new branch (branch_b), make my change and create a new Pull Request, ask for review and merge again?
Or is there a "cleaner" way, when the first Pull Request is somehow merged with the second one and we don't have to make 2 different merges?
If another change requested is a part of the same feature as in ‘branch_a’, then you can simply make change in the same branch, your PR request will show up those changes, but PR approval will be required again.
If another change requested is outside the scope of feature ‘branch_a’ and it is just a file is same between two changes, then you can create a new branch out of master say ‘branch_b’, complete your changes and raise PR for the same. After ‘branch_a’ is merged into master, you can rebase your second branch ‘branch_b’ to include updated master codebase into branch_b, (or vice-versa if branch_b is merged first).
This is especially useful if the order of merge is not decided in advance.
Below are the steps, for rebase, here ‘feature_branch’ is the name of your branch for which you want to perform rebase:
git checkout master
git pull origin master
git checkout feature_branch
git rebase master
Here you might get some conflicts(if there are any) multiple times as per number of commits in your feature_branch. You can resolve the conflicts manually and proceed with further process of rebase with below command:
git rebase --continue
At any point if you think that things are not going well and you would like to cancel rebase process, then execute below command:
git rebase --abort
Finally when all conflicts are resolved and you get message as successfully merged, then execute below command to push changes to origin:
git push --force origin feature_branch
for more information on rebase process follow link:
https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase
Branch off the first pull request branch, edit, add, commit, push, and ask for a second PR merging to the first branch. When the first branch is merged the second PR will be reconfigured automatically (by GitHub) to be merged into the main branch.

How to add a commit done on a restored branch to an old PR?

In the PR , after I merged a branch and deleted it, I restored the branch again on the PR.
Locally, then I made changes to the branch and pushed it to the remote branch. The commit is available on the remote branch but it does not come up in the existing merged PR.
After I compare and Pull Request, it is creating a new PR.
Is it possible to add the commit to the old PR itself?
No, you can't re-open the pull request if it was merged.

How to make PRs from a fork default to targeting the fork instead of the original?

Say there is an origin repo called original/repo of which I forked off to my/repo. If I create a branch in my/repo and then create a PR from that branch, the PR defaults to merge to original/repo. How can I make it default to merging to my/repo?
That (changing the default PR target) is a known request
But it is not supported yet by GitHub, which means you would need to
duplicate your fork into its own GitHub independent repository, in which you can do your internal PRs, before being able to
push to your fork, where you can do regular PR to the upstream original repository.

How to Update a Pull Request on Github

I have a feature branch on git and I set is as a Pull Request.
I've made 3 commits to the feature branch but the latest commits are not showing up in the pull request page.
Is there a way to update my pull request to show the latest commits from the feature branch?
Check first your git status
you must be on the feature branch and not on a detached HEAD
your branch should be ahead of origin/feature branch
the remote feature branch should be the one from which the PR has been initiated.

github pull request from a single branch

I have forked a master from upstream, and have created two branches from it. Is it possible to send in PR from a single branch?
I did that, and despite the github web UI is creating the PR against a single branch, I noticed the changes from the other branch is included in the PR request as well.
What's the correct way to send in PR from a single branch?
The likely problem is you didn't git checkout master before creating the second branch, then the second branch you created is descendant from the first branch you created. Just checkout to master before adding the second branch.