Git and GitHub
A brief introduction
Git
- version control system
- works offline (repositories exist on your computer)
- tracks changes via commits
- has a command-line interface and integrations with GUIs (like RStudio)
GitHub
- web-based platform built around Git
- provides a remote location for hosting Git repositories
- enables collaboration
- offers other features for project management (pull requests, issue tracking)
Our Git/GitHub goals
- For you: Keep track of progress on projects
- Go back when you need to
- Don’t lose old work
- Easily search the history of a project
- For others: Share your work
- Have a place to store and link to code
- Read and interact with others’ code
There is a lot to learn about this topic and I am not an expert on everything!
What we won’t cover
- Collaboration
- When multiple people are working on the same GitHub project, things get a little more complex
- I went though almost my whole PhD without working on shared GitHub projects and only now do I feel semi-confident collaborating!
- I think it’s best to figure things out in your own projects first
- Git on the command line
- There are a lot of functions you might hear about (
git fetch
, git merge
, etc.)
- RStudio and GitHub will have everything we need!
Workflow
Create a repository (clone from GitHub, or create on your computer and connect to GitHub)
- Write some code!
- When you complete “something”, add it to the staging area
- Write a brief description of what you did (“added linear model”; “created table 1”) and commit
- Push to GitHub
- Repeat!
As long as you are working on your own, all on the same computer, you don’t need to worry about pulling
What is a commit?