We will explain here 2 use cases:
- [[ https://c4science.ch/w/c4science/rstudio/#you-use-r-or-rstudio-but | You use R or Rstudio but no projects, you are already versioning your work but no integration from within Rstudio ]]
- [[ https://c4science.ch/w/c4science/rstudio/#setting-up-from-scratch | You want to set up an Rstudio project on c4science from scratch ]]
[[ https://c4science.ch/w/c4science/sshkeys/ | Both use cases need SSH keys to be already set up. ]]
# 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".
# Setting up from scratch
You first need to create a repository on C4science.
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: type the following on your command line, from within the R Project directory:
git remote add origin ssh://email@example.com/diffusion/997/simplegitrepo.git
Change the `ssh://` URL to whatever is your repo's URL. Now you can push your commits to C4science.