We will explain here 2 use cases:
- You use R or Rstudio but no projects, you are already versioning your work but no integration from within Rstudio
- You want to set up an Rstudio project on c4science from scratch
- Clone a repository on c4science from within Rstudio
You use R or Rstudio but no projects, you are already versioning your work but no integration from within Rstudio.
While working on Rstudio on your files, associate your work with a project with the New Project dialog: File -> New project
and choose Existing directory
Choose the directory (if you launched Rstudio from it it should be already there) and Create project. This, in pracctice, will create an .Rproj file and modify your .gitignore (check it out with git diff .gitignore)
The system is smart enough to detect if you are using Git. On the bar, you should see a small "Git" icon.
From the Git icon, you can do all the common Git operations you would do on the command line.
If you choose Git -> commit..., you will be presented with the "Review Changes" panel, which is pretty straightforward. You tick the files you want to "Add", add a commit message and click commit. Once this is done, you can click on "Push".
From within Rstudio, you create a new project with File -> New Project, choose New directory. You then have to pick the type of Project (standard, package, shiny). If you are familiar with R, you'll know what to choose. If you're not, choose Empty Project. Choose a directory name etc and tick the Create a git repository box.
What you have done here included a git init on the Rproject folder. You should now see a Git symbol on the toolbar.
You can now work on your files and commit, but you need to add an origin to be able to push to c4science: from Rstudio, lauch a shell via Tools -> Shell and type the following:
git config --global user.email "YOUR@EMAIL" git config --global user.name "C4SCIENCE_USERNAME" git remote add origin ssh://email@example.com/diffusion/997/simplegitrepo.git git push --set-upstream origin master
Change the email and the username to yours and ssh:// URL to whatever is your repo's URL. Now you can push your commits to C4science.
In RStudio, click New project as normal. Choose Version Control. Then, pick Git or SVN. Then, enter the repo data. Rstudio will clone the project into the chosen directory and, if needed, create an .Rproj file. You're now good to go with Rstudio and c4science. You can use the Git menu and commit + push from within Rstudio.