
This is Part 1 of a two-part series on version control in bioinformatics. Part 1 covers the history of Git, its use with GitHub, and a hands-on worked example. Part 2 looks at real-world bioinformatics workflows and the practices we have found useful when a repository is shared by a team.
The worked example is deliberately small: a repository that installs FastQC and MultiQC, so that the quality-control step of a short-read NGS workflow can be reproduced by anyone who clones it.
Version control tools fall into two broad generations, and the distinction explains much of how Git is used today.
The first generation was centralised: a single repository on a server held the history, and users checked files in and out of it. Examples include SCCS (1972), RCS (1982), CVS (1990) and Subversion (2000). These systems are straightforward to reason about, but they depend on the server being reachable, and branching is comparatively expensive.
The second generation is distributed. In a distributed system every clone carries the full history, so committing, branching and inspecting history happen locally, without a network round-trip. Git was created in 2005 by Linus Torvalds to manage the Linux kernel source tree; Mercurial appeared the same year. Git stores the repository as a sequence of snapshots addressed by content hash, which makes branching and merging inexpensive.
Hosting platforms came next. GitHub launched in 2008, adding a web interface on top of Git and, with it, the pull request — a way to propose, discuss and review a set of changes before they are merged. This post uses Git and GitHub, but the underlying model is shared with other distributed systems such as Mercurial.
The person who creates the repository is its administrator and can configure who may read or modify it. A few settings are worth deciding at the start:
public if the work is meant to be shared with the community, otherwise private.README.md for general users, a README.developer.md can carry developer-specific notes.
Cloning copies the repository to a local computer. When several people work together, each keeps their own copy and GitHub acts as the shared central location — similar to a cloud drive — that keeps the copies in sync.
GitHub offers SSH authentication for transferring resources, but it does not behave like a remote server with shell access.
The official GitHub documentation describes how to add an SSH key to an account: adding a new SSH key to your GitHub account.
Add the public key under Settings → SSH and GPG keys:
Then test the connection:
ssh git@github.com# PTY allocation request failed on channel 0# Hi nttg8100! You've successfully authenticated, but GitHub does not provide shell access.# Connection to github.com closed.With authentication working, clone the repository:
-b <branch-name>.# clone (equivalent to: git clone git@github.com:nttg8100/ngs-quality-control-for-blog-example.git -b main)git clone git@github.com:nttg8100/ngs-quality-control-for-blog-example.gitcd ngs-quality-control-for-blog-exampleOpen the folder in an editor. The examples here use Visual Studio Code (download):
A repository is just a folder, so it can be opened in a terminal-based editor. In Visual Studio Code, that is:
code .Everything in the repository is a text file and can be edited directly.
A branching strategy is a workflow for handling changes to a codebase in a structured way. Branches allow work on a feature, a fix, or an experiment without disturbing the main codebase.
Common branch types:
main or master): the stable branch that holds production-ready code.feature/quality-control), keeping development isolated until the work is complete.develop branch to integrate features before they reach main.main (for example hotfix/fix-typo) and merged back after testing.A typical workflow:
main for the feature or fix.main (or develop).This keeps main stable, makes collaboration easier, and lets changes be reviewed before they are merged.
For the small project used here, feature branches are merged directly into main:
# Create and switch to a new branch from maingit switch -c feature/environment-setupThe environment is created with Pixi rather than conda. A Makefile records the installation so it can be repeated; it can be written by hand or generated from the shell. In the example below the target is named after the Pixi binary it installs, so the command make ~/.pixi/bin/pixi runs that recipe.
A Makefile is used by the make build tool. It defines rules for building and managing a project — commonly C or C++ code, but it works equally well for Node.js, React, or TypeScript projects when repetitive tasks need automating.
Key concepts:
cat << EOF >> Makefile${HOME}/.pixi/bin/pixi: mkdir -p ${HOME}/.pixi/bin curl -sSL https://pixi.sh/install.sh | shEOF
# Verify the newly created file contentcat MakefileTwo habits make a Makefile easier to maintain: use .PHONY for targets that do not produce a file of the same name, so the recipe always runs; and keep the steps modular, separating environment setup, tool installation, and analysis into distinct targets.
# Install piximake ~/.pixi/bin/pixi
# Initialize pixi in your current repositorypixi init --channel conda-forge --channel bioconda
# Install multiqc and fastqcpixi add fastqc multiqc
# Activate the pixi shellpixi shell
# Verify tools are installedwhich fastqcwhich multiqc# <repo>/.pixi/envs/default/bin/fastqc# <repo>/.pixi/envs/default/bin/multiqcGit history records who made each change, which is useful when a change needs to be traced later.
git status shows the files that have not yet been committed:
git status
Files are staged for a commit with git add. They can be added one at a time, or all at once:
# Add files one by onegit add .gitignoregit add .gitattributesgit add Makefilegit add pixi.lockgit add pixi.toml
# Or add all files/folders in the current repositorygit add .
# Verify staged filesgit status
If a file is staged by mistake, it can be removed from the staging area without losing the file:
# Create a wrong filetouch wrong_file.txtgit add wrong_file.txt
# Restore it to unstaged statusgit restore --staged wrong_file.txt
Files that should stay local can be listed in .gitignore, which prevents them from being committed even when git add . is used. .gitignore accepts both files and folders.
.gitignore in the specific folder where the unwanted files live..env, .pixi), node_modules, data folders (data), archives (*.tar.gz), and caches (__pycache__).!:folder!folder/file.txt# Add to gitignoreecho "wrong_file.txt" > .gitignore
# View the filecat .gitignore
# Try to add the file again—it won't be staged now and will show a warninggit add wrong_file.txt
# Check statusgit status
Create a commit from the staged files:
git commit -m "feat: add pixi setup"
Push the branch to GitHub:
# Push to remotegit push origin feature/environment-setup
# View your remote origin to confirm where updates are pushed# This shows I cloned using the SSH credentialgit config --get remote.origin.url# git@github.com:nttg8100/ngs-quality-control-for-blog-example.git
The new branch appears in the GitHub repository. In this example: https://github.com/nttg8100/ngs-quality-control-for-blog-example
A pull request (PR) compares a branch's changes with the target branch. GitHub shows what has been added or removed, so the change can be reviewed by the author, by a teammate, or with assistance such as Copilot.
Practices that tend to make review easier:
Closes #123).To open a PR, use the Pull requests tab, click New pull request, then choose the source and target branches:
The pull request is now open:
Reviewing a PR is as much about the description as the diff:
Click Files changed to review and comment on specific lines. When the author is also the reviewer, GitHub disables self-approval, so in practice another person reviews the work. LGTM (Looks Good To Me) is a common way to signal approval before the branch is merged.
Branch protection rules are configured in the repository settings; GitHub documents the options in configuring pull request merges.
GitHub offers three merge strategies for a pull request:
| Strategy | Description | Use case |
|---|---|---|
| Merge commit | Combines all commits from the feature branch into the target branch, preserving full history. | Default; keeps detailed commit history. |
| Squash and merge | Combines all changes from the feature branch into a single commit on the target branch. | Clean, concise history for small features. |
| Rebase and merge | Reapplies the branch's commits on top of the target branch, creating a linear history. | Linear history, avoids merge commits. |
On a larger team, a merge commit integrates a branch directly into the target branch, which works well when the target has not changed much since the branch was created. If teammates have merged work that touches the same files, conflicts appear; in that case it is often better to rebase the branch onto the latest target before merging. When a branch holds many small incremental commits, squash and merge collects them into a single commit and keeps the history tidier.
After the merge, main shows the change from the pull request:
In a shared repository, main may receive updates while a feature branch is being developed. Rebasing replays the branch's commits on top of the latest main, which keeps the history linear and reduces the chance of a complex conflict later.
For example, suppose a branch feature/testing-rebase was started from an older main, and new commits have since landed on main. To update the feature branch:
# Make sure you're on your feature branchgit checkout feature/testing-rebase
# Fetch the latest changes from the remote repositorygit fetch origin
# Rebase your branch onto the updated main branchgit rebase origin/mainIf a conflict occurs, Git pauses the rebase. After resolving it:
git add <resolved-files>git rebase --continueTo abandon the rebase:
git rebase --abortRebasing keeps the branch history linear and easier to review, and reduces the likelihood of tangled merges later. Because the commit history changes, the branch usually needs a force-push afterwards:
git push --force-with-leaseForce-pushing deserves care, particularly on a branch that others are also using.
Once the branch is merged and the local copy is in sync, the next piece of work starts from an updated main:
# check out on base branch where feature is updatedgit checkout main
# pull to update, add rebase for better organization on commitsgit pull --rebase origin main
# create new branchgit switch -c feature/add-cicd-setupThis is Part 1 of a two-part series on version control in bioinformatics. Part 2 continues with real-world examples and shared-repository workflows.



