Why does a bioinformatician need Git?
Imagine you are running a GATK variant-calling pipeline. You tweak a parameter, your script breaks, and you cannot remember what it looked like before. Or you share your RNA-seq analysis with a colleague and they cannot reproduce your results because you have been editing the script all week. These are exactly the problems Git solves.
Git is a version control system. It tracks every change you make to your files over time, so you can always go back to any earlier version. Think of it as an unlimited "undo" button for your entire project — except smarter, because it remembers who changed what, when, and why.
In bioinformatics, Git is used to track analysis scripts (R, Python, Bash), pipeline configuration files (Snakemake, Nextflow), and small data-processing utilities. Large data files (FASTQ, BAM, VCF) are not tracked in Git — those go on HPC shared storage or cloud object storage.
How Git works — the three areas
Before installing anything, you need to understand the three places Git stores your work. Confusing these is the most common cause of mistakes for beginners.
| Area | What it is | Bioinformatics analogy |
|---|---|---|
| Working directory | The actual files on your disk — what you see in your terminal | Your open R script in a text editor |
| Staging area (index) | A holding zone — you choose which changes to include in the next snapshot | Your lab notebook page you are about to sign off |
| Repository (.git) | The permanent record of all snapshots (commits) — stored in a hidden .git/ folder |
The signed, dated page in your lab notebook, never to be erased |
The staging area exists so you can make many small edits but only commit the ones that logically belong together. For example, you might edit both your Snakemake pipeline and your README at the same time — but you can stage and commit them separately, keeping your history clean and readable.
git add, then permanently record them with git commit. That snapshot lives in the repository forever.
Install Git on Ubuntu
Ubuntu (and Debian-based Linux systems used on most HPC clusters) uses the apt package manager to install software. It downloads Git from the official Ubuntu software repository, automatically handles dependencies, and registers it so it is available system-wide — which is why we need sudo (superuser permission).
On HPC systems where you do not have sudo, you will install Git via conda instead — we cover that in Module 3.
Step 1 — Update the package list
This tells Ubuntu to fetch the latest list of available software versions. Always run this before installing anything, so you get the current Git version rather than a stale one from months ago.
sudo apt-get update
You will be prompted for your Ubuntu password. Type it and press Enter — the cursor will not move as you type (this is normal Linux security behaviour).
Step 2 — Install Git
The -y flag automatically answers "yes" to the confirmation prompt, so the installation runs without pausing.
sudo apt-get install -y git
Step 3 — Confirm the installation
Check that Git installed correctly and see its version number. You should see output like git version 2.43.0 — the exact number does not matter as long as it is 2.x.
git --version # Expected output: git version 2.43.0
sudo apt-get update again and then the install command. If you are on a restricted HPC system, use conda install -c conda-forge git instead — we cover this in Module 3.
Configure Git — your global identity
Git records who made each commit. Before you make your first commit anywhere, you must tell Git your name and email. This is a one-time setup that applies to all repositories on your machine.
Every commit in Git is permanently stamped with the author's name, email, and timestamp. This is what makes Git a trustworthy scientific record — when you look at a project's history, you can see exactly who changed a parameter in the alignment script, and when. When you push your commits to GitHub, your name and email appear next to each change.
Use the same email as your GitHub account — this is how GitHub links your commits to your profile and makes your contribution graph green.
Set your name
The --global flag means this setting applies to every Git repository on your machine, not just the current one. Replace the placeholder with your actual name.
git config --global user.name "Shajedur Rahman Hossain"
Set your email
Use the exact email linked to your GitHub account. This is how GitHub connects your commits to your profile page.
git config --global user.email "your@email.com"
Set the default branch name to main
Historically Git named the default branch master. GitHub and most of the scientific community now use main instead. Setting this globally means every new repository you create will automatically use main, matching what GitHub expects — avoiding a confusing mismatch the first time you push.
git config --global init.defaultBranch main
Set your preferred text editor
Git sometimes opens a text editor — for example, when you write a longer commit message. The default editor is vi, which confuses beginners. Set it to nano instead, which works just like any simple text editor.
git config --global core.editor nano
--global settings are saved in a file called ~/.gitconfig in your home directory. You can always open it with nano ~/.gitconfig to see or edit your settings directly.
Verify your configuration
After setting everything, always verify it. One typo in your email will mean your commits are not linked to your GitHub profile — causing your green contribution graph to stay empty even after pushing.
git config --list prints every setting Git knows about — your name, email, editor, colour preferences, and more. The --global flag limits it to only the settings stored in ~/.gitconfig, not any project-specific overrides. Always run this after setup to catch mistakes before they affect your commit history.
git config --global --list # Expected output — your values will differ: user.name=Shajedur Rahman Hossain user.email=your@email.com init.defaultbranch=main core.editor=nano
Read the raw config file directly
You can also view your config file directly. This is useful if you ever need to edit it by hand.
cat ~/.gitconfig # You will see something like: [user] name = Shajedur Rahman Hossain email = your@email.com [init] defaultBranch = main [core] editor = nano
git config --global again on this machine — these settings persist and apply to every repository you create or clone.
Quick reference — Lesson 1 commands
| Command | What it does | When you use it |
|---|---|---|
| sudo apt-get update | Refreshes Ubuntu's package list | Before installing any software |
| sudo apt-get install -y git | Installs Git from the Ubuntu repository | One-time setup on a new machine |
| git --version | Prints the installed Git version | Verifying the installation succeeded |
| git config --global user.name "…" | Sets the name stamped on every commit | One-time setup per machine |
| git config --global user.email "…" | Sets the email stamped on every commit | One-time setup per machine |
| git config --global init.defaultBranch main | Makes new repos default to branch "main" | One-time setup to match GitHub |
| git config --global core.editor nano | Uses nano as the default editor for commit messages | One-time setup for beginners |
| git config --global --list | Shows all global Git settings | Verifying configuration |
| cat ~/.gitconfig | Displays the raw configuration file | Viewing or editing settings directly |
Exercises
Complete all three exercises before moving to Lesson 2. The goal is to end this lesson with Git installed, configured, and verified on your Ubuntu machine.
apt-get update, apt-get install -y git, then git --version. Paste the version line you see in the terminal into a text file called setup-notes.txt — you will push this file to GitHub in Lesson 2.
▶ Show expected output
git version 2.43.0 # (your version number may differ — anything 2.x is fine)
git config --global commands from this lesson, using your real name and the email you used to create your GitHub account. Then run git config --global --list and confirm that all four settings appear correctly.
▶ Show expected output
user.name=Shajedur Rahman Hossain user.email=your@email.com init.defaultbranch=main core.editor=nano
cat ~/.gitconfig and observe the INI-style format Git uses. Note the section headers in square brackets ([user], [init], [core]) and how each setting is indented beneath its section. This format is important to recognise when troubleshooting Git problems on HPC systems where you edit the file directly.
▶ Show expected output
[user] name = Shajedur Rahman Hossain email = your@email.com [init] defaultBranch = main [core] editor = nano