Git and GitHub
GitHub is a web-based platform for hosting and sharing code. It is built on top of Git, a tool that tracks changes to files over time.
In practical terms, Git allows you to:
- Record changes to your scripts
- Revert to earlier versions if needed
- Document when and why changes were made
GitHub provides an online location where those tracked files can be stored, backed up, and shared with others.
Below we will provide a quick tutorial on Git and GitHub, highlighting the basic tools you should be familiar with. If you need further clarification or wish to learn about more advanced features (e.g. branching, merging), GitHub has excellent tutorials on their documentation site.
Why use GitHub for Omics Analyses?
Omics workflows are often complex, and there is rarely a single “correct” way to analyze a dataset. Even when working with the same raw data, researchers may make different — yet reasonable — choices at each processing step.
For example, to analyze scRNA-seq data:
- Counts may be normalized using a simple log1p(CPM) transformation or a more sophisticated method such as
scTransform. - Cells may be filtered using thresholds of 100 genes, 200 genes, or another cutoff entirely.
- Differential expression may use a p-value threshold of 0.01 or 0.05.
- Different software packages or parameter settings may be used for clustering or dimensionality reduction.
The number of reasonable analysis paths is enormous.
This complexity is further compounded by:
- Differences in package versions
- Changes in software dependencies
- Random seeds used in stochastic algorithms
- Differences in computing environments
As a result, even identical code can produce different — yet equally reasonable — results on different machines. Because of this, it can be difficult for others to evaluate, critique, or reproduce your analysis workflow unless the exact scripts and parameters are available.
For this reason, when publishing omics analyses, we strongly recommend saving your analysis scripts and configuration files to a public GitHub repository. Doing so allows other researchers to inspect your exact workflow and build upon your work.
What Should (and Should Not) Go on GitHub
Before creating a repository, it is important to understand what belongs there.
Files to Put on GitHub
- Analysis scripts (.R, .py, .sh)
- Jupyter notebooks (.ipynb)
- SLURM job scripts (.sbatch)
- README files
- Small configuration files
- Environment files (environment.yml, requirements.txt)
- Small processed summary tables
Files That Should NOT Go on GitHub
- FASTQ files
- BAM or CRAM files
- Count matrices
- Intermediate alignment outputs
- Any file larger than ~100–200 MB
Large omics data files should remain on the HPC or in dedicated storage systems — not on GitHub.
Creating a Repository
Step 1: Create a Repository on GitHub
- Log in to GitHub.
- Click New Repository.
- Choose a repository name.
- Leave it empty (do not initialize with a README).
- Click Create Repository.
GitHub will display a repository URL, such as:
https://github.com/<git_username>/<project_name>.git
Step 2: Initialize Git Locally
Navigate to your project directory (on your local machine or HPC):
cd /path/to/projectInitialize Git:
git initThis creates a hidden .git directory that tracks changes.
Step 3: Connect to GitHub
Add the GitHub repository as a remote using the repository URL:
git remote add origin https://github.com/<git_username>/<project_name>.gitBasic Git Workflow
You only need three core commands for everyday use: add, commit, and push. First, add selects the files whose changes you want Git to track. Next, commit records those changes as a snapshot in your local repository along with a message describing the update. Finally, push uploads those committed changes to the remote GitHub repository so they are saved online and visible to others.
Add Files
To add changes to a single file:
git add <filename>To add all changes:
git add .Commit Changes
git commit -m "Commit Description"A commit message should briefly describe what changed.
Push to GitHub
git push -u origin mainAfter the first push, future pushes can be made with:
git pushUsing a .gitignore File
We usually keep all of our files for an analysis in a single project directory, and it is inconvenient to physically separate out the files that should be saved to GitHub and the ones which should not.
The .gitignore file tells Git which files it should not track. If you do not already have a text file called .gitignore in your repository, you should create one.
An example .gitignore file for an omics analysis project might look like this:
# Raw sequencing data
*.fastq
*.fastq.gz
# Alignment files
*.bam
*.bai
*.sam
# Large matrices
*.mtx
*.h5ad
*.rds
# Temporary files
*.log
*.tmp
# MacOS system files
.DS_StoreHere, the asterisk (*) is a wildcard that matches any filename with the specified extension. This .gitignore file tells Git to ignore all FASTQ files, BAM files, large matrices, temporary files, and MacOS system files. You can also use .gitignore to ignore specific directories (e.g. data/) or files with specific names (e.g. config.yaml).
Note that if you have already added a file to Git (e.g. with git add .), it will be tracked even if it matches a pattern in .gitignore. To stop tracking a file that has already been added, you can use:
git rm --cached <filename>This will remove the file from Git’s tracking but keep it on your local filesystem. After running this command, the file will be ignored in future commits.