This describes the process of working with a Git(Hub) repository. It is fairly specific to STAT545 and to using Git(Hub) with R stuff, so don’t expect a general tutorial.
We assume the following
We do not cover software installation and set-up here! This is just about usage.
I assume we are talking about the private GitHub repository that STAT545 has granted you. If your name is “Jennifer Bryan”, your repo should be named zz_jennifer_bryan-coursework. Assuming you are logged in to GitHub, you should be able view (and edit online) this repo at a URL like so (link won’t work because it’s a fake example!):
You only do this once! If you’ve already set this up, read and confirm but don’t redo this. See Plan B.
Go through the process described in Step 3 of Test drive RStudio and Github to establish a new connection between an existing remote GitHub repository and a new local repository.
When you first do this, you accomplish two things:
README.md you created via the browser, to you local repoThis is called “tracking a remote” in Git jargon. Learn more than you ever wanted to here.
If you think you’ve already established this connection, here’s how you can check.
Launch RStudio and open the Project that you believe to be the Git repo associated with your coursework and to be tracking the correct repo on GitHub.
Get into a shell (RStudio > Tools> Shell …).
Enter pwd to see working directory and re-confirm that you are indeed in the correct directory.
Enter git remote -v.
Here’s what I see (note I’m in the main repo for STAT 545 content):
origin https://github.com/STAT545-UBC/STAT545-UBC.github.io.git (fetch)
origin https://github.com/STAT545-UBC/STAT545-UBC.github.io.git (push)
You should see something like that, but for your private STAT545 repository.
I assume you’ve got some local work completed or can do some now. I’ll wait….
Commit these changes to your local repo.
From RStudio:
We will pull any changes that are on the GitHub repo but not yet on your local version. Why?
If RStudio is behaving well as your Git client, you should be able to use the blue “pull” arrow button.
You can also do this from the command line with git pull. Here’s what you’ll see if there’s nothing to pull, which is probably the case:
Jennifers-MacBook-Pro-3:STAT545-UBC.github.io jenny$ git pull
Already up-to-date.
If RStudio is behaving well as your Git client, you should be able to use the green “push” arrow button.
You can also do this from the command line with git push. After I made some edits to this document and in the topic index, here’s what my push looked like:
Jennifers-MacBook-Pro-3:STAT545-UBC.github.io jenny$ git push
Counting objects: 13, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 5.97 KiB | 0 bytes/s, done.
Total 10 (delta 7), reused 0 (delta 0)
To https://github.com/STAT545-UBC/STAT545-UBC.github.io.git
c82b90b..89b984e master -> master
That’s an example of a successful push.
Now just … repeat. Do work somewhere. Commit it. Push it or pull it depending on where you did it, but get local and remote “synced up”. Repeat.