Git is a version control system — it tracks changes to files over time and lets multiple people work on the same project without overwriting each other's work. GitHub is a website that hosts Git repositories and makes collaboration easier.
The lab's code, website, and resources (including this toolkit) all live on GitHub. You need to know the basics.
Jump to:
- Core Concepts
- Getting Started
- The Basic Daily Workflow
- Essential Commands
- Writing Good Commit Messages
- What to Put in Git (and What Not To)
- GitHub for Collaboration
- Learning More
Repository (repo): A folder tracked by Git. Every project has one.
Commit: A saved snapshot of your changes. Think of it as a checkpoint you can always return to.
Branch: A parallel version of the repo. You make changes on a branch without affecting the main version until you are ready.
Push / Pull: Push sends your local commits to GitHub. Pull brings changes from GitHub down to your machine.
Clone: Download a copy of a repo from GitHub to your computer.
Install Git:
- Mac: Git is usually pre-installed. Check by running
git --versionin Terminal. - If not installed: download from git-scm.com or install via Homebrew (
brew install git)
Configure your identity (do this once):
git config --global user.name "Your Name"
git config --global user.email "your@email.com"Clone a repo:
git clone https://github.com/rkn2/repo-name.git# See what has changed
git status
# Stage the files you want to commit
git add filename.py
# Or stage everything changed
git add .
# Commit with a message describing what you did
git commit -m "Add damage classification function"
# Push to GitHub
git push| Command | What it does |
|---|---|
git status |
Show what has changed since last commit |
git log |
Show commit history |
git diff |
Show exactly what changed line by line |
git pull |
Get latest changes from GitHub |
git add <file> |
Stage a file for committing |
git commit -m "message" |
Save a snapshot with a description |
git push |
Send commits to GitHub |
git checkout -b branch-name |
Create and switch to a new branch |
A commit message should complete the sentence: "If applied, this commit will..."
Good:
Add tornado damage classification modelFix off-by-one error in GPR depth calculationUpdate figure 3 to use consistent color scale
Not useful:
updatefix stuffchanges
You will thank yourself when you need to find something in the history six months later.
Put in Git:
- Code and scripts
- LaTeX files and
.bibfiles - Markdown documentation
- Small configuration files
Do not put in Git:
- Large data files (use DesignSafe, Google Drive, or a data repository instead)
- Compiled outputs (PDFs,
.pycfiles) - Credentials or API keys — never commit passwords or tokens
- Jupyter notebook outputs if the notebooks are large (clear outputs before committing)
Use a .gitignore file to tell Git to automatically ignore certain file types.
When working with Rebecca or labmates on a shared repo:
- Pull before you start working — always run
git pullfirst to get the latest version - Use branches for new features or experiments — don't work directly on
main - Open a Pull Request when your branch is ready — this lets Rebecca review before merging
- Communicate about conflicts — if two people edited the same file, Git will flag a merge conflict; don't panic, just talk it through
- Interactive tutorial: learngitbranching.js.org — visual, hands-on, highly recommended
- GitHub Docs: docs.github.com — comprehensive reference
- Pro Git book: git-scm.com/book — free, thorough, worth reading the first few chapters