How to time travel with your code

Foundations of Git connectivity with RStudio

Git
Github
Version Control
Beginner
Author

Simisani Ndaba

Published

April 30, 2022

meetup flyer

Meetup Details

Gracielle Higino covers foundations of version control, useful git commands and connections with RStudio. Gracielle generously edited the recording on YouTube which you can find at the bottom of the page.

About the Speaker


Gracielle is an open science enthusiast and advocate. Her research and background in Ecology and Evolution helps her understand the world, while her open science skills help her change it. Born and raised in Brazil, living in Canada, working globally through science, volunteers work on science communication and open leadership, and as a Mozilla Festival wrangler.

Contact Speaker


Follow Gracielle on X (formerly Twitter) @GracielleHigino

Take a look at her work on graciellehigino.com and email her on graciellehigino@gmail.com

Foundations of Git connectivity with Rstudio

Using the course notes on Using GitHub. Gracielle explains using the web-based software platform called GitHub, which is designed for collaboration and version control. GitHub is a place to discuss changes and issues related to that content, and collaborate on creating more content together. You’ll store the collection of files related to your Study Group, called a repository, on GitHub. GitHub also is the software that will power your Study Group Website. While GitHub was developed by and for software engineers, you don’t have to be an expert coder to use it. This section will take you through some of the basics.

Collaboration, Version Control, & GitHub


One of the main challenges in working with many people on a single project-- whether it’s planning and running multi-institution research initiative to collect and analyze data or the process of co-creating, sharing, and updating learning materials for your study group-- is “version control,” the task of managing the many contributions your group makes to shared working documents.

Your contributors may be spread around the world or working in the same room; they may be working simultaneously or asynchronously. No matter how your group is organized, the work of many contributors needs to be wrangled into a single project. Version control manages this process: it stores a history of changes and who made them, allowing you to revert or go back to earlier versions of those documents, and understand how contributions by different contributors have changed the project over time.

You may have used word processing software that has a “changes,” “history” or “revisions” feature, which also allows you to see and revisit any changes to the document: this, too, is a form of version control. If you’ve never used GitHub or any other specialized version control software before, it may help to look at some diagrams and define some new terms before you get started.

When we code, write text, or create any kind of content using computers, we end up with a collection of files in a folder or directory, also known as a repository, or “repo.”

repository

Some Git command best practises


Best practices - committing -


  • Write short messages with action verbs (e.g., “fix import data code”)

  • Try to commit every saved change, or group saved changes by theme (e.g., when adding a reference to a manuscript, this change only makes sense when the citation is committed as well)

  • Add emojis for fun and quick reference!

  • Attention to large files

Best practices - push & pull -


  • Always start your day with git pull!

  • Always finish your day with git push!

  • Don’t wait until the end of your day to push…

  • Push & pull as often as possible

best practices - branching -


  • Use the main branch only for fundamental changes

  • When working on teams, have a convention for naming the branches (you can “nest” branches using / - e.g.: INTRO/ecological_niche)

  • Pull requests are safer! Only merge final changes.

  • Always branch to test new things – never do it on the main

Collaborative notes


Slides

sotware carpentry notes on version control

usethis package documentation

usethis package documentation 2

emoji guide for commit messages

Configuring notifications

Collaboration, Version Control, & GitHub

Useful book: happygitwithr

Configuring git with R


install.packages(“usethis”) library(usethis) use_git_config(user.name = “Your Name”, user.email = “your@email.org”)

create PAT


usethis::create_github_token()

store your PAT


gitcreds::gitcreds_set()