Download presentation
Presentation is loading. Please wait.
1
GIT AND GITHUB WORKSHOP
Lab Meeting March 16, 2017 I’m presenting a brief workshop on git, github and R integration Learned a lot of these techniques from Jenny Bryan Found it super useful, especially working from multiple stations and has a lot of promise for collaboration Has anyone used git? Heard of git/github? What do they know? David Tavernini
2
Outline Introduction Rationale: Smooth workflow Prevents headaches
Becoming more prevalent Computers shouldn’t be intimidating Outline: Introduction to VC Local git* git in R* Using git remotely* Perks of GitHub* Simply put, git is a version control system. Allows you to track changes, make edits, and revert to previous states. When I learned it, I found it very beneficial and gives me more confidence in my edits Very smooth workflow Prevents headaches Becoming more prevalent in collaborative environments Command line can be scary, but I hope I can make it a bit easier I’ll first give a brief outline of version control and what git actually is Provide a brief tutorial on using git locally (within one computer) Integrating git with Rstudio DISCLAIMER: Not an expert and there are many features available that I don’t know how to utilize. I’d recommend looking deeper if you are trying to do anything you perceive as complex.
3
Uncertainty in edits you make
Introduction Problem: Numerous file edits Uncertainty in edits you make Need to log changes (collaborative environment) Solution: Maintain accessibility of certain editing milestones Track changes, when they were made, and who by What is the point of version control: Typically you anticipate making numerous edits to your files You are unsure if your edits will be better in the long run You need to track changes, especially prevalent in a collaborative environment when you want to see others changes
4
Version Control Version Control
For this, we use version control, which allows you to revert to previous changes. Has anyone experienced this method? What if I told you there’s a better way?
5
What is git? git locally Version control system
Keeps a log of noted changes in repository Repository “repo”: Directory where git operates Saves snapshots of repo when user makes a “commit” Branching Analogy: filing cabinet So git is a version control sytem. It operates in a repository, which is simply a file directory initialized by git. Essentially you assign a directory to be a repository and git keeps a log of any changes which occurs in that directory. Once initialized, as you make changes to the files within, you commit changes, which is essentially telling git to take a snapshot of the directory and keep it in a log. Conceptual model After initializing a directory, you make changes to files in your working directory. When ready you “stage” them for changes and commit them to take a snapshot of the current space It also allows for branching which allows you to divert off the current series of snapshots to make changes without affecting the orginal stream of work.
6
git locally TIME Heres a diagram of a typical git workflow.
7
git demonstration git locally Context:
Have an empty directory for your project workspace Setup directory for git Add files, make changes, commit Branch off and make changes So let’s try it out. We’ll start with the fundamentals. In this example we will try and get a directory initialized for a project, add some files make some changes
8
git demonstration git locally Context:
Have an empty directory for your project workspace Setup directory for git Add files and make changes Branch off to make changes So let’s try it out. We’ll start with the fundamentals. In this example we will try and get a directory initialized for a project, add some files make some changes Obligatory disclaimer: working in console CAN cause damage if you don’t know what you are doing.
9
git with R git in R Project directories
Allows a directory to be specified as project Sets working directory to be within project Integrating with git R provides basic graphical user interface (GUI) Many limitations, good for basic use What’s nice is that git allows us to integrate its functionality within an R environment. Who uses Rstudio? Anyone work with project files
10
git + R Demonstration git in R Context:
You need to setup a directory for R work Initialize R project with Git Create scripts Make commits Branching
11
What is GitHub? GitHub Free online service to act as a remote repo
Users make changes, commit to local repo, and push to GitHub When multiple machines are used, you can push and pull Analogy: common filing cabinet
12
Advantages GitHub Works well in collaborative environment:
Tracks changes from multiple authors Good documentation of changes Works especially well with text/Markdown documents Optionally allows open access Others can clone your repo and make improvements E.g. create a model script for others to use/develop Github is very good for a collaborative environment: Check history of commits, and who made them Discussions Issues Explore hadleys repo
13
Integrating git, Github and RStudio
Context: Creating a project shared among others Open a repo in GitHub Begin project in R Clone to local computer Make changes and commit Obligatory disclaimer: refrain from putting any (current or future) sensitive information on github.
14
Optional: Fork/Pull request
Fork off other repos within github Make changes and make pull request Experimental exercise
15
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.