Before you start
- A little command-line comfort helps. New to it? Do the Command-line basics lesson first.
- You'll make a free GitHub account in this lesson.
- Any term new? The Glossary has it.
Learning objectives
By the end of this lesson you will be able to: run the everyday Git loop (init, add, commit) to snapshot your work, write clear commit messages, create a repository on GitHub, and push your code online so collaborators and employers can see it.
Why scientists need version control
You already version your work, just badly. Everyone has a folder like this: analysis_final.R, analysis_final_v2.R, analysis_FINAL_actually.R. It's a mess, you can't remember what changed between versions, and if you delete the wrong one, that work is gone.
Version control fixes this. It keeps a complete, labelled history of your project, so you can see exactly what changed and when, go back to any earlier version, and never lose work. For science specifically it does something even more important: it makes your analysis reproducible. Anyone (including you, six months later) can see precisely which version of the code produced a result.
Decode the jargonVersion control
Version control is a system that records changes to files over time so you can recall any earlier version. Instead of saving copies by hand, you take labelled "snapshots" as you go. The tool that does this for code, almost universally, is Git.
Git vs GitHub: they are not the same thing
This trips up almost everyone at first, so let's be clear.
- Git is the tool that runs on your computer. It takes the snapshots and keeps the history. It works completely offline.
- GitHub is a website that stores copies of your Git projects online. It's where you back them up, share them, collaborate, and show your work to the world.
An analogy: Git is like the "track changes" and save-history feature built into your computer. GitHub is like Google Drive, the cloud you sync those files to so others can see them. You can use Git without GitHub, but together they're how modern science and software get done.
Decode the jargonRepository (repo)
A repository, or repo, is just a project folder that Git is tracking. It holds your files plus the entire history of changes. A repo can live only on your computer, or be pushed up to GitHub so it has an online home too.
1Set up Git once
Git usually comes pre-installed on Mac and Linux (and on Windows via the Git for Windows installer or WSL). Check, then tell Git who you are so your snapshots are signed with your name.
git --version # confirms Git is installed git config --global user.name "Your Name" git config --global user.email "you@email.com"
You do this once per computer. Use the same email as your GitHub account.
2The everyday loop: add, commit, push
This is the heart of Git, and it's just three verbs you'll repeat thousands of times. Imagine you've been editing an analysis script.
git add analysis.R # stage the file you want to snapshot git commit -m "Add GC-content calculation" # take the snapshot, with a note git push # upload the snapshot to GitHub
That's the loop. add chooses what goes in the snapshot, commit saves it with a short message describing the change, and push sends it to GitHub. Do this whenever you finish a meaningful chunk of work.
Decode the jargonCommit
A commit is one saved snapshot of your project at a moment in time, with a short message saying what changed. Your project's history is just a chain of commits. Good commit messages ("Fix sample-order bug in metadata") are a gift to your future self.
3Start a repo and connect it to GitHub
To put an existing project under version control and onto GitHub: create the repo on GitHub's website (the green "New repository" button), then, in your project folder, connect and push.
git init # start tracking this folder git add . # stage everything in it git commit -m "First commit" git remote add origin https://github.com/you/your-repo.git git push -u origin main
After that first setup, your daily life is just the add / commit / push loop from step 2.
⚠️ Never commit large data or secrets
Git is for code and small text files, not multi-gigabyte FASTQ files or private passwords and API keys. Keep big data out (store it elsewhere and fetch by accession) and list sensitive files in a .gitignore file so Git skips them. A leaked key on a public repo is a real and common mistake.
Why this matters for your career
Here's the part that's easy to miss: a GitHub profile is a scientist's portfolio. When you apply for a bioinformatics role, a public repo with a clean RNA-seq analysis and a clear README says more than any line on a CV. It proves you can do the work, write readable code, and document it. Every project you finished in the earlier tracks belongs on your GitHub. We'll build that portfolio deliberately in a later lesson.
🔶 Level up: branches and pull requests
Once the basic loop is second nature, the next ideas are branches (a safe parallel copy to try changes without touching your working version) and pull requests (proposing those changes back, the way teams review each other's work). You don't need them on day one, but they're how collaboration happens. GitHub's own Hello World guide walks through them gently.
Check your understanding
git commit do?git push is the separate step that uploads commits to GitHub..gitignore for anything sensitive.git add before you commit?git add chooses what goes into the snapshot, git commit saves that snapshot with a message, and git push sends it to GitHub. They are three separate steps.