"The goal of reproducible research is to tie specific instructions to data analysis and experimental data so that scholarship can be recreated, better understood and verified." Max Kuhn, CRAN Task View: Reproducible Research
Peng 2011, Science 334(6060) pp. 1226-1227
In this module you will explore the use of software called Git to manage 'versions' of files. Similar to 'track-changes' in Microsoft Word, Git keeps track of any edits and makes it possible to track who made the change and when. Git (and other version control software) are most commonly used to manage collaboratively edited code, but it can keep track of any file.
- Verification & Reliability: Find and fix bugs. Today's results == tomorrow's.
- Transparency: increased citation count, broader impact, improved institutional memory
- Efficiency: Reduces duplication of effort. Payoff in the (not so) long run
- Flexibility: When you don’t 'point-and-click' you gain many new analytic options.
- Enter data in Excel
- Use Excel for data cleaning & descriptive statistics
- Import data into SPSS/SAS/Stata for further analysis
- Use point-and-click options to run statistical analyses
- Copy & paste output to Word document, repeatedly
These steps can be very difficult to reproduce (even for the same person at a later date)!
Payoffs
- Eases collaboration
- Can track changes in any file type (ideally plain text)
- Can revert file to any point in its tracked history
Costs
- Learning curve
- Strong support for non-linear development: Rapid branching and merging, specific tools for visualizing and navigating a non-linear development history.
- Distributed development: No central server needed, each user has a full copy
- Efficient handling of large projects: Designed to manage the Linux OS
- Cryptographic authentication of history: The ID of a particular version depends uponthe complete history. Once published, it is not possible to change the old versions without it being noticed.
Everything checksummed before storage and then referred by checksum.
It’s impossible to change the contents of any file or directory without Git knowing. You can’t lose information in transit or get file corruption without Git being able to detect it.
A way of reducing digital information to a unique ID:
A 40-character hexadecimal SHA-1 hash: 24b9da6552252987aa493b52f8696cd6d3b00373
Git doesn't care about filenames, extensions, etc. It's the information that matters...
The important stuff is hidden in the .git folder.
GitHub is a web-based Git repository hosting service. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project. Wikipedia
There are other ways to use Git, you can host your own server or use another private company, such as BitBucket.
You can think of GitHub as part:
- Server to back up your files
- Website to share your files
- Method to track changes to your files
- Platform to collaboratively develop code (or other files)
sudo apt-get install git
or similar
Creating an account on GitHub
- Create a GitHub account at https://github.com/
- This will be a public account associated with your name
- Choose a username wisely for future use
- Don't worry about details, you can fill them in later
- Create a repository called demo
- Add a brief and informative description
- Choose "Public"
- Check the box for "Initialize this repository with a README"
- Click "Create Repository"
- Go to RStudio
- File -> New Project
- Version Control: Checkout a project from a version control repository
- Git: Clone a project from a repository
- Fill in the info:
- URL: use HTTPS address
- Create as a subdirectory of: Browse and create a new folder called
GEO503(or similar)
To set up a connection that doesn't require you to type in your password every time, see here
- Edit: make changes to a file in the repository you cloned above
- Stage: tell git which changes you want to commit
- Commit (with a message)
- Push: send the updated files to GitHub
Select which changed files (added, deleted, or edited) you want to commit.
Add a commit message and click commit.
Click the green arrow to sync with GitHub.
RStudio has limited functionality.
$ git help <verb>
$ git <verb> --help
$ man git-<verb>
For example, you can get the manpage help for the config command by running git help config
Similar to info in git tab in RStudio
git config shows you all the git configuration settings:
user.emailremote.origin.url(e.g. to connect to GitHub)
Branches used to develop features isolated from each other.

Default: master branch. Use other branches for development/collaboration and merge them back upon completion.
$ git checkout -b devel # create new branch and switch to it
$ git checkout master #switch back to master
$ git merge devel #merge in changes from devel branch
But we won't do much with branching in this course...
Check out the (free) book ProGIT
Or the cheatsheet.
Remember, the data and code are real, the products (tables, figures) are ephemeral...
Update the YAML header to keep the markdown file
From this:
title: "Untitled"
author: "Adam M. Wilson"
output: html_documentTo this:
title: "Demo"
author: "Adam M. Wilson"
output:
html_document:
keep_md: trueAnd click knit HTML to generate the output
- Use File -> New File -> R Markdown to create a new markdown file.
- Use the Cheatsheet to add sections (
#and##) and some example narrative. Stage,Commit,Push!- Make more changes then
Stage,Commit,Push! - Explore the markdown file on your GitHub website.
"An article about computational result is advertising, not scholarship. The actual scholarship is the full software environment, code and data, that produced the result." Claerbout and Karrenbach, Proceedings of the 62nd Annual International Meeting of the Society of Exploration Geophysics. 1992
- Slides based on Ben Marwick's presentation to the UW Center for Statistics and Social Sciences (12 March 2014) (OrcID)
- Git Slides based on materials from Dr. Çetinkaya-Rundel












