GitHub Classroom
- From Homework 4 (which will be published today), the rest of the assignments (homework and projects) will be submitted through GitHub Classroom.
- We will practice how to use GitHub Classroom during today’s lecture to make sure everyone is comfortable with using it.
- A test assignment has been created for us to practice.
- To add yourself to the classroom and start the test assignment, click the following link:
Test Assignment
- After you add yourself to the class and start the assignment, a new repository has been created with the name
test-assignment-GitUsername
with GitUsername
as your Git username.
- For example, for me, my repo is named
test-assignment-nkha149
.
- Now, clone the repo to your local laptop using the instructions shown in Git & GitHub lecture notes.
- A folder named
test-assignment-GitUsername
is created in your computer.
- The location of this folder depends on where you ran the
git clone
command.
- Inside this folder, there is a RMarkdown file named
test-assignment.Rmd
.
- Open this file in RStudio and follow the instructions there to edit the file.
- After you are done, now stage (add) the file:
- The
-A
at the end is to stage all local changes.
- If you only want to stage a particular file, use
git add <filename>
.
git add -A
git commit -m "your message"
- Push the change to the remote repo (on GitHub):
git push origin master
- Go back to github.com to check if the your remote repo is updated!
Git & RStudio
- Next, we will use RStudio to connet with GitHub.
- Don’t worry! This is much easier than using the command line (but also more prone to errors).
- Another assignment has been created for us to do this.
Clone the new GitHub repository to your computer via RStudio
- In RStudio, start a new Project:
- File > New Project > Version Control > Git.
- In “Repository URL”, paste the URL of your new GitHub repository.
- Accept the default project directory name, which coincides with the GitHub repo name.
- Take charge of – or at least notice! – where the Project will be saved locally.
- I suggest you check “Open in new session”, as that’s what you’ll usually do in real life.
- Click “Create Project”.
- Now, look at the bottom corner screen of your RStudio window, look for “Files” tab.
- All the files inside your Git repo are now shown there.
Make changes, stage, commit and push changes via RStudio
- Follow the instruction inside
rstudio-test.Rmd
to make changes to the file.
- Now, from RStudio:
- Click the “Git” tab in upper right pane.
- Check “Staged” box for README.md.
- If you’re not already in the Git pop-up, click “Commit”.
- Type a message in “Commit message”, such as “Commit from RStudio”.
- Click “Commit”.
- Go back to github.com to check if the your remote repo is updated!