I created a pull request on project on GitHub to a specific remote branch. After some time, the remote branch was deleted.
How can I change the pull request to point to another branch (specifically master
)?
I created a pull request on project on GitHub to a specific remote branch. After some time, the remote branch was deleted.
How can I change the pull request to point to another branch (specifically master
)?
You can now change the base branch of an open pull request. After you’ve created a pull request, you can modify the base branch so that the changes in the pull request are compared against a different branch. By changing the base branch of your original pull request rather than opening a new one with the correct base branch, you’ll be able to keep valuable work and discussion.
Click the Edit button by the title of the pull request to reveal the base branch selector.
You can't. Just make a new pull request.
Although undocumented, you can do this using the GitHub REST API.
The usage of the API is explained in this answer, but basically you can issue a REST request like this one:
$ curl --user "tom" \
--request PATCH \
--data '{"issue": "15", "head": "tom:new-branch", "base": "master"}' \
https://api.github.com/repos/fred/fabproj/pulls
This will change the pull request embodied by issue 15 on the fred/fabproj
repo to use the new-branch
branch on the tom/fabproj
fork.
Edit: Note: according to comments, the above is only for attaching a new pull request to an existing issue.
As of 08/15/2016 this is now possible natively via Github:
You can now change the base branch of an open pull request. After you’ve created a pull request, you can modify the base branch so that the changes in the pull request are compared against a different branch. By changing the base branch of your original pull request rather than opening a new one with the correct base branch, you’ll be able to keep valuable work and discussion.
I could change the target branch. It is true that we cannot edit the name of target branch in the PR. But the trick is to rename the branch to something else, and rename your target branch to that of present already in PR.
Example: My PR is having name like "dev-4.9". There is another branch which is named "qa-4.9". All I want is that "qa-4.9" should be the PR target branch. Steps:1 1) Re-name branch "dev-4.9" to something else "original-dev-4.9"
git checkout dev-4.9
git branch -w original-dev-4.9
git push origin original-dev-4.9
2) Re-name branch "qa-4.9" to "dev-4.9".
git checkout qa-4.9
git branch -w dev-4.9
git push origin dev-4.9 -f (force push to write entire branch to reflect dev-4.9)
3) Refresh PR url and see the commits in qa-4.9 reflected over there.
Instead of losing all the comments connected with a PR to a deleted branch:
For example, you have a PR to branch1, which is deleted. You now want to merge to master and retain comments on your existing PR:
This is a bit hacky, but far better than destroying lots of comments.
you're supposed to use github api.
curl --user "your_github_username" \
--request PATCH \
--data '{"title":"newtitle","body":"newbody",...}' \
https://api.github.com/repos/:owner/:repo/pulls/:number
you can find the detailled list of data in github developer doc
curl --user "jeremyclement" \
--request PATCH \
--data '{"title":"allows the control of files and folders permissions."}' \
https://api.github.com/repos/Gregwar/Cache/pulls/9
it seems that the fields head/label
and head/ref
are not editable. For now, the only solution seems to be that of Amber