Interact with GitHub
Overview
Teaching: 5 min
Exercises: 10 minQuestions
How to sync your files with GitHub
How to get remote changes on your local machine?
Objectives
Push
updates to GitHub
Pull
updates from GitHub
Push
changes to GitHub
In the previous episode, we explored the difference in between the local commit history and the commit history on the GitHub remote.
Rstudio gives you a warning about the status of your local commits versus those stored on GitHub.
Rstudio note on
ahead of
If the Git pane displays your branch is ahead of ‘origin/master’ by X commits, this is actually providing you a warning message saying there is no backup of these commits!
In order to store these changes on GitHub as well, we have to push our changes to GitHub.
Push to GitHub
- Click push in the git pane
- Go to your repository on GitHub to verify the commits and file contents
Store credentials
It is a tedious task to retype the password each time you want to push anything to GitHub. Luckily, you can store your credentials when using https.
Configure password
- Click on the
more
button in thegit
pane and selectShell
- Type
git config --global credential.helper store
- Type
exit
to quit the shell
Pull
changes from GitHub
When working from different computers or when you adapted some text online in GitHub, it is important to integrate these adaptations on your local computer. To do so, you can pull
changes from Github.
Pull changes from GitHub
- Update the
README.md
file online and commit the changepull
the changes to your local machine- Open the
README.md
file in Rstudio and check if the file has changed.
Key Points
Push
our code to GitHub andpull
your code from GitHub