stonar96 stonar96 - 2 months ago 14
Git Question

Github move master to branch with PR?

I have forked a project, cloned it, made changes on master and commited and pushed these changes. Then I have created a PR from master to the original repo also to master. So the PR already exists and has lots of comments and stuff which I don't want to loose.

My question: Is it possible to move the master branch to a new branch to use the master branch for other things and then edit the PR so that the "from branch" is the new branch?

Answer

No, GitHub doesn't allow you to do this. (They do allow you to change which branch you want to merge into, but not the branch you are merging from.) This is why I usually try to create a new branch for any PRs, even if it's just a small change.

However, you can still work on other things without changing the name of your branch. Assuming upstream is the remote for the original repo, do e.g.:

git checkout -b my-new-feature upstream/master

This will give you a new feature branch (my-new-feature) based on the upstream version of master.

The other option is to close the existing PR, rename the branch, open a new PR that links to the old PR for reference. (If you include e.g. Replaces PR #123 in the description, GitHub will convert #123 to a link to PR #123.)

Comments