What is Git? Install & Configure

Understand version control, install Git on Ubuntu, and set your global identity — the one-time setup every bioinformatician must do before writing a single commit.

✓ Free lesson Module 2 · Lesson 1 of 7 ⏱ 35 min
Lesson 1 · ⏱ 35 min · 🐧 Ubuntu · Beginner

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.

💡 What is Git, exactly?

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.

🔁
Version history
Every saved state of your script is stored. Roll back at any time.
🌿
Branching
Try a new approach without breaking your working pipeline.
🤝
Collaboration
Work with supervisors and colleagues on the same codebase.
📦
Reproducibility
Share the exact code version used for a publication figure.
🌱 Real example: When publishing your Sorghum genomic selection results, you can tag the exact Git commit used to produce each table and figure. A reviewer can clone your repository and reproduce the results exactly — a standard increasingly required by journals.

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
💡 Why three areas?

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.

🧬 The Git workflow in one line: You edit files in the working directory, stage the ones you want with git add, then permanently record them with git commit. That snapshot lives in the repository forever.

Install Git on Ubuntu

💡 Why apt-get?

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.

📁 Run from: anywhere — this is a system command
bash
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.

📁 Run from: anywhere
bash
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.

📁 Run from: anywhere
bash
git --version

# Expected output:
git version 2.43.0
⚠️ If you get "command not found": the installation failed. Try running 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.

💡 Why does Git need your name and email?

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.

📁 Run from: anywhere — this writes to ~/.gitconfig
bash
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.

📁 Run from: anywhere — this writes to ~/.gitconfig
bash
git config --global user.email "your@email.com"

Set the default branch name to main

💡 Why set the default branch name?

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.

📁 Run from: anywhere
bash
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.

📁 Run from: anywhere
bash
git config --global core.editor nano
📝 Where does this go? All --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.

💡 What does --list do?

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.

📁 Run from: anywhere
bash
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.

📁 Run from: anywhere
bash
cat ~/.gitconfig

# You will see something like:
[user]
    name = Shajedur Rahman Hossain
    email = your@email.com
[init]
    defaultBranch = main
[core]
    editor = nano
Your Git setup is complete. You never need to run 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
Advertisement Support free bioinformatics education

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.

1 Install Git and check the version
Run the three installation commands in order: 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
bash output
git version 2.43.0
# (your version number may differ — anything 2.x is fine)
2 Configure your global identity
Run all four 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
bash output
user.name=Shajedur Rahman Hossain
user.email=your@email.com
init.defaultbranch=main
core.editor=nano
3 Read your .gitconfig file
Run 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
bash output
[user]
    name = Shajedur Rahman Hossain
    email = your@email.com
[init]
    defaultBranch = main
[core]
    editor = nano
Advertisement Your ad could appear here