## Using Rstudio with GIN

Rstudio is a very nice application that was created to write and run R code. It now also has the possibilities to run python code and create reproducible reports in Rmarkdown (there are also specific tools to deal with citations in these reports). It also has git functionalities, allowing to `commit` (save a new version of your repository locally), `pull`(download changes existant on the server but absent of your local folder) and `push` (save all new versions present locally to the server version).

You need first to make sure git is installed and found by Rstudio: go the menu `tools > global options > git` browse to the git.exe if Rstudio did not find it automatically (a git.exe is installed together with the gin-cli, but you can also install another via https://git-scm.com/downloads. Find a walkthrough on how to set up ssh here: https://happygitwithr.com/ssh-keys.html. What you are asked to do on github will be done on GIN (https://gin.g-node.org/user/settings/ssh).

You can now download new repositories using `file > new project... >>version control >> git` insert the ssh link you get on the gin repository page (for this repo `git@gin.g-node.org:/larkumlab/Dealing_with_Gin.git`) and decide the folder name and where to save it on your machine. I put all my repositories in a special `gin` folder in my document folder, but this is up to you to organise your files.

You can then make changes, on the right part of the Rstudio window, you can access a `git` tab, where changed files are listed. You can then use the buttons of the tab to commit changes, pull, or push commits to GIN. Git advices:

- make small commits
- give commits a meaningfull comment which will allow you to spot changes easily in the history tab
- if you are working on different machines, do not forget to pull changes when you start working, and push before you go.


