This content is from the fall 2016 version of this course. Please go here for the most recent version.
You only have to do this once per machine.
RStudio can only act as a GUI front-end for Git if Git has been successfully installed AND RStudio can find it.
A basic test for successful installation of git is to simply enter git
in the shell. If you get a complaint about git
not being found, it means installation was unsuccessful or that it is not being found, i.e. it is not on your PATH
.
If you are not sure where the git executable lives, try this in a shell:
which git
(Mac, Linux)where git
(most versions of Windows)If Git appears to be installed and findable, launch RStudio and try again. If it still doesn’t work, quit and re-launch RStudio if there’s any doubt in your mind about whether you opened RStudio before or after installing Git.
From RStudio, go to Tools > Global Options > Git/SVN and make sure that the box Git executable points to the Git executable. It should read something like:
/usr/bin/git
(Mac, Linux)C:/Program Files (x86)/Git/bin/git.exe
(Windows)On my computer, it looks like this:
If you make any changes, restart RStudio and try the steps at the top of the page again.
Still not working? Try googling your problem or speak with myself or the TA.
myrepo
In RStudio, start a new Project:
https://github.com/bensoltoff/myrepo.git
.
/cfss
directory and clone all your repos there.This should download the README.md
file that we created on GitHub in the previous step. Look in RStudio’s file browser pane for the README.md
file.
Why setup your R projects this way? There’s a big advantage to the “Github first, then RStudio”" workflow: the remote GitHub repo is now the “upstream” remote for your local repo. In essence, you are already setup to push and pull commits to GitHub. There is no need to set anything else up through the shell or a Git client.
Sometimes you cannot always setup the GitHub repo first, or you already have an RStudio project you need to connect to a GitHub repo. This workflow is the reverse of the above and cannot be executed from within RStudio.
myrepo
(or whatever you named the GitHub repo)git remote add origin https://github.com/bensoltoff/myrepo.git
git pull origin master
git push -u origin master
Do this every time you finish a valuable chunk of work, probably many times a day.
README.md
file by adding the line “This is a line from RStudio”. Save your changes.Do this a few times a day, but possibly less often than you commit.
You have new work in your local Git repository, but the changes are not online yet.
Before you push your changes to GitHub, first you should pull from GitHub. Why? If you make changes to the repo in the browser or from another machine or (one day) a collaborator has pushed, you will be happier if you pull those changes in before you attempt to push.
[master dc671f0] blah
3 files changed, 22 insertions(+)
create mode 100644 .gitignore
create mode 100644 myrepo.Rproj
Now just rinse and repeat. Do work somewhere. Commit it. Push it or pull it depending on where you did it, but get local and remote “synced up”.
This work is licensed under the CC BY-NC 4.0 Creative Commons License.