In this set of exercises, you can continue to work on the
Git directory you created yesterday (we’ll be following the
Existing
project, GitHub last path). Alternatively (e.g., if you encounter
any issues), you can also follow the New project,
GitHub first approach and start from a new GitHub
repository. Regardless of which option you choose, Exercises 2 to 5
should work the same.
In order to do the following exercises, you should have gone through the steps described in the setup information for the workshop. Specifically, you should…
Git via
RStudioHTTPS for GitHubGit
initialized that you should have created yesterday. After that, create a
GitHub repository and connect it to your local project.
You first need to create a local RStudio project and
associate it with the existing directory you created yesterday
(Git should be initialized there and, ideally, all files
that you want to be tracked and connect to the remote GitHub
repository should already be staged and committed). Next, you need to
create a GitHub repository and connect it to your local
project. If you need some help (or further information), check the Existing
project, GitHub last section in Happy Git and GitHub for
the useR.
You can create a new RStudio project in an existing directory via File -> New Project -> Existing Directory. As we will start working on the project right away, also check “Open in new session”.
If you have initialized Git in that directory, the
Git tab should be visible in the newly opened
RStudio instance (ideally, all files that you want to be
tracked should have been added and committed).
usethis::use_github(private = TRUE) in
R/RStudio (but you can also go
through the steps manually).
Git tab. To make extra sure that
everything worked, let’s check the Git status of our
project via the Terminal in RStudio.
Terminal in
RStudio uses via Tools -> Global Options
-> Terminal. If you use Windows, you should choose
Git Bash (which you should have installed with
Git for Windows).
git status
Now that the project is set up and in sync with the remote
repository, we can start working on it. Modify the README file (just
add, remove or edit a few words). If you have not already done so, add
(stage & commit) the R Markdown report (and its
resulting output) you generated yesterday to your repository/project.
Instead of (or in addition to) editing the README, you could also edit
the .rmd file.
Git.
Git tab in RStudio and their status will be
indicated as modified (M) or untracked (??).
Git tab.
Git tab in RStudio, write a commit message in
the menu that opens up, and then click the Push button in the
same menu.
You can edit the README via the small pen icon next displayed above the content of your README file on the website of your GitHub repository.
Remember that if you edit a file directly via the GitHub web interface, you also need to make a commit (and add a commit message).Git tab in RStudio to update your
local project.