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.
Use the dev version:
## not run
devtools::install_github("r-lib/usethis")Open the local project for the repo and pull changes, either by clicking on the PULL button in RStudio or as follows:
git2r::pull()## Already up-to-date
Look for the pull request number in the list of pull requests. We see that the pull request we want is number 1.
usethis::pr_fetch(1)## ✔ Checking out PR 'jtr13/usethis_demos/#1' (@nbrgraphs): 'Add line'
## ✔ Adding remote 'nbrgraphs' as 'https://github.com/nbrgraphs/usethis_demos.git'
## ✔ Creating local branch 'nbrgraphs-patch-1'
## ✔ Setting upstream tracking branch for 'nbrgraphs-patch-1' to 'nbrgraphs/patch-1'
## ✔ Switching to branch 'nbrgraphs-patch-1'
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.