Skip to content
New course: Interactive Dashboards with Shiny. Get 50% off with coupon SHINYLAUNCH.
R for the Rest of Us Logo

Keep RStudio and GitHub in Sync

This lesson is locked

Get access to all lessons in this course.

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

  1. Create a README.md in the github-first project and add some text

  2. Stage this file (and any other modified files) and add a commit message

  3. Hit commit

  4. After you commit, push your changes to GitHub

  5. Go to your GitHub repository and make sure you see your changes

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Juan Clavijo

Juan Clavijo

October 21, 2021

I get this error message after running use_github(): Error in curl::curl_fetch_memory(url, handle = handle) :

David Keyes

David Keyes

October 21, 2021

Can you upgrade the curl package by typing install.packages("curl") in the console and then try again? I Googled this error and see several people suggesting this.

I just got the following error while trying to push an updated for my course project:

>>> C:/Program Files/Git/bin/git.exe push origin HEAD:refs/heads/master To https://github.com/MmattC/CourseProject.git ! [rejected] HEAD -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/MmattC/CourseProject.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Charlie Hadley

Charlie Hadley

December 2, 2021

Hey Matt! The error is happening because there are changes on the remote version of the repo (the GitHub version) and you can't push your changes until you have pulled the changes from GitHub.

This is a good design decision by git. The remote version of the repo is the "real version" of the repo, it's what your collaborators or anyone wanting to replicate your work would use. We could call it the "canonical version of the code". You therefore aren't allowed to push your changes to the remote version until you have pulled the canonical version.

To fix this follow these steps:

  1. Make sure everything is committed
  2. Press pull 2a) if that happens without issue move to 3 2b) if you're told about conflicts, send me an email.
  1. Press push

Daniel Dunleavy

Daniel Dunleavy

April 13, 2022

Two questions:

  1. In a project with a lot of commits, is there a way to easily spot which changes were made locally and which were made in GitHub?

  2. Any thoughts/preferences on the GitHub desktop app vs. online interface? Pros and cons?

Charlie Hadley

Charlie Hadley

April 13, 2022

I need to break this down a little bit to answer.

The GitHub website provides an interface to edit files directly in the web browser. This is functionally the same as making a commit from your local machine, as you need to provide a commit message. It's often convenient to do this for quick changes. After doing do so you would need to then pull the latest version of the repository to your local machine.

The GitHub desktop app is a useful GUI for managing repositories on your local machine. It's functionally the same as using the terminal, command prompt or the RStudio git tab. The only difference being that a local commit must be pushed to GitHub whereas edits made within the web interface are made directly to the repository.

Underlying GitHub is git - the actual version control software. There isn't a mechanism in this software to identify which "client" was used to make a commit. As far as I can tell there is no functional way to identify through the GitHub interface which client was used to make a commit.

Does this answer your questions?

Jessica Brewer

Jessica Brewer

October 7, 2022

When I created the README.md file in my github-first project, I also had a .gitignore file and a .Rproject file show up in the Git window, so I committed all three and pushed to GitHub. Is this ok?

David Keyes

David Keyes

October 7, 2022

Yup, those files get created automatically. You're all good!

I work with extremely sensitive data that cannot be stored in Github for privacy reasons. What would be the best ways to ensure the data is never pushed to Github, only the scripts? Would I just never select the "Staged" checkbox for the dataset(s), or are there other settings or best practices to avoid pushing the data itself?

Charlie Hadley

Charlie Hadley

November 12, 2022

Hey Emma,

There are several different options for working with GitHub and sensitive data. I think that it's worthwhile checking out the responses to David's Twitter question on this topic.

Cheers,

Charlie

And I'll just chime in and say that the main message from that Twitter thread is to never put sensitive data on GitHub. Instead, you can write code that pulls data in from wherever it's stored. However, this code should require an API key or some other mechanism so that, if someone were to get access to your code, they wouldn't be able to run it themselves and get access to your data. Hope that helps!