Skip to content

Instantly share code, notes, and snippets.

@jsumners
Created March 3, 2021 12:54
Show Gist options
  • Save jsumners/461ef7a64545108635cc437fde112721 to your computer and use it in GitHub Desktop.
Save jsumners/461ef7a64545108635cc437fde112721 to your computer and use it in GitHub Desktop.
Start new PR with an existing PR as a base

Ocassionally, someone will start a pull request and, for various reason, not see it through. Later, someone else may wish to finish that work. Even though the original author was unable to finish their work, we should still include their efforts in our project's history. To do so, the person wishing to finish the original pull request should start their new pull request using the original as the base.

The simplest workflow to accomplish this is:

$ # For the project on GitHub to your account and then:
$ git clone <your fork of the-project.git>
$ git remote add the-project-oa https://github.com/<original-author>/<the-project>.git
$ git checkout -b my-feature
$ git pull the-project-oa patch-1 # "patch-1" being the original author's feature branch name
$ # make changes
$ git add . && git commit -m 'Add my tests'

The above example assumes the original pull request still applies cleanly to the project. If there are merge conflicts, then the workflow gets trickier. At a minimum, it would look something like:

$ # For the project on GitHub to your account and then:
$ git clone <your fork of the-project.git>
$ git remote add the-project-oa https://github.com/<original-author>/<the-project>.git
$ git checkout -b my-feature
$ git pull the-project-oa patch-1 # "patch-1" being the original author's feature branch name
$ git rebase master # or whatever the default branch of the project is
$ # resolve the conflicts using `git mergetool` or whatever you normally do
$ # make changes
$ git add . && git commit -m 'Add my tests'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment