Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

How to edit a pull request locally, part 1

Joyce Robbins April 05, 2019


Here we employ usethis functions to modify a pull request locally. Without these functions, the process is much more complicated and error prone. Note that the preferred workflow is to ask the person who submitted the changes to make the modifications that you request. You would only do this editing yourself, following the steps below, in a situation in which the contributor is not responding, or does not have the skills to make the changes you need. It will only work if the “Allow edits from maintainers” box is checked when the pull request is made. This is the default and is yet another reason why pull requests are most natural from a non-master branch.

Install usethis

Use the dev version:

## not run

Open local version of repo

Open the local project for the repo and pull changes, either by clicking on the PULL button in RStudio or as follows:

## Already up-to-date

Find and fetch the pull request

Look for the pull request number in the list of pull requests. We see that the pull request we want is number 1.

## ✔ Checking out PR 'jtr13/usethis_demos/#1' (@nbrgraphs): 'Add line'
## ✔ Adding remote 'nbrgraphs' as ''
## ✔ Creating local branch 'nbrgraphs-patch-1'
## ✔ Setting upstream tracking branch for 'nbrgraphs-patch-1' to 'nbrgraphs/patch-1'
## ✔ Switching to branch 'nbrgraphs-patch-1'

Fix the PR

You are now on the PR branch:

git status
## On branch nbrgraphs-patch-1
## Your branch is up to date with 'nbrgraphs/patch-1'.
## nothing to commit, working tree clean

Make changes as desired, then save and commit them.

Now we’re ready for Part 2.