with RStudio
BIO 8940 - Lecture 3
2024-09-19
This won’t even touch the surface of git… But! Hopefully, you:
Recognize the power of using version control
Know the basic tools to get started using git
Where to go for help
You need:
RStudio or VS Code
R
a github account
git software
R packages:
usethis
gitcreds
Use RStudio projects to keep materials associated with a particular analysis together
Self contained and portable
Working directory set to root of project on launch
Fresh session everytime the project is launched
See Jenny Bryan’s post on project oriented workflows for more details
File > New Project > New Directory
So You don’t like RStudio
💔
Essentially a Rstudio Project:
organise all the files within a given project folder
set project folder as working directory
ensure a fresh, clean session
simply, do the same without using RStudio 🤩
The management of changes to documents, computer programs, large web sites and other collections of information.
Open source (free to use) Version control software.
A website that allows you to store your Git repositories online and makes it easy to collaborate with others.
git
on your computerxcode-select --install
sudo apt install git
dnf install git
For more details got to https://git-scm.com/downloads
Before git only through the terminal 😢
Now git can be used via multiple user-friendly interfaces
RStudio + usethis
📦 + gitcreds
📦 == ❤️ Git
& GitHub
🤩
But When using VS Code
to be done only once
To check your configuration
Set your configuration
Use your github username and and the email you used to sign-up on GitHub
Need scopes repo, users, workflows at least
Store your git token with credentials
Provide your github PAT token in the window
Restart RStudio and R
Git and github access should be configured now
Might be problematic the first time you do it
create R project
initialise it for git
Accept the commit and restart R
In R, to create github repo and link it
et voila
create new empty folder for your project(no space, no accent)
add at least one file in it (suggest README.md)
using terminal/shell
et voila
Create new repository on github
Set R working directory where you want to save your project
To clone (and link) github repo to your computer
et voila
repository your project folder
commit a snapshot of your repo
push send commits to a remote
pull get commits from a remote
clone get the repository from the remote for the first time
branch a movable label that points to a commit
merge combining two branches
remote a computer or server with the repository on it
1.view file status
2.stage files
3.commit changes
README
. Explain what your project is, and how to use it.
usethis::use_readme_md()
usethis::use_readme_rmd()
LICENSE
. Without a licence, the contents of the repository are technically closed.
usethis::use_ccby_license(name = "Julien Martin")
?licenses
: details of functions available to generate licensesCONTRIBUTING.md
- guidelines for contributors.
usethis::use_tidy_contributing()
provides a realtively strict but instructive templateCODE_OF_CONDUCT.md
set the tone for discourse between contributors.
use_code_of_conduct()
A backup of your repository (Dropbox is NOT a backup)
Work with others (not covered)
Increase your visibility
Increase interactions with users
Easy distribution of R packages (without CRAN submissions)
one more time just in case Dropbox is NOT a backup
When you want to merge branches:
create a pull request on Github
check for incompatibilities
then merge
git
BIO 8940 - Lecture 3