GitHub essentials · Lesson 4 of 4
Module 3 · The command line · GitHub essentials
Run code in the browser, freeze the version behind a result with a release, make your code citable with a DOI, build a portfolio, meet GitHub Actions, and keep data and secrets out of every repository.
GitHub is more than a backup. It is where much of science's code is published, reviewed, cited and reused. This lesson covers what turns a repository into a piece of work you can show: running it in the cloud, freezing the exact version behind a paper, making it citable, a portfolio page, simple automatic checks, and the rules that keep data and secrets safe.
Run code in the browser
Notebooks (.ipynb) appear on GitHub as readable pages, with code, outputs and figures, so a reviewer can read your analysis without running it. To run a public notebook in Google Colab, replace github.com in its address with colab.research.google.com/github.
GitHub Codespaces opens a repository in a ready-made computer in the cloud, with an editor and terminal in your browser, so you can work with nothing installed. On the repository page choose Code › Codespaces › Create codespace on main. Personal accounts get a free monthly allowance (at the time of writing, 120 compute hours and 15 GB of storage); stop codespaces you are not using, under github.com/codespaces, so they do not use it up.
Freeze the version behind a result: releases
Code changes after a paper or report is written. A release marks the exact version you used, so you and others can always get it back. A release is built on a tag, a name fixed to one commit, usually a version number such as v1.0.0.
- On the repository page choose Releases in the sidebar, then Draft a new release.
- Under Choose a tag, type v1.0.0 and choose Create new tag.
- Give the release a title, for example Analysis for the 2027 poster, and describe what it contains. Generate release notes lists the merged pull requests for you.
- Choose Publish release. GitHub attaches a ZIP of the code at that moment.
A common pattern is v1.0.0 for the first finished version, v1.0.1 for a small fix, v1.1.0 for an added feature and v2.0.0 for changes that break the old way of using it.
Make your code citable
- CITATION.cff: a small text file in the top folder that says how to cite the work. GitHub then shows a Cite this repository link in the sidebar, which gives a ready-made citation in APA and BibTeX.
- A DOI through Zenodo: Zenodo is a free research archive run by CERN. Sign in to Zenodo with your GitHub account, switch on the repository in Zenodo's GitHub settings, and from then on each GitHub release is archived with its own DOI, a permanent identifier you can put in a paper's methods or data availability statement.
cff-version: 1.2.0
message: "If you use this code, please cite it as below."
title: "LSMA practice analysis"
authors:
- family-names: "Smith"
given-names: "Alex"
orcid: "https://orcid.org/0000-0000-0000-0000"
version: 1.0.0
date-released: 2027-01-15
license: MIT
repository-code: "https://github.com/your-username/lsma-practice"Replace the example name, ORCID, dates and address with your own; leave out orcid if you do not have one yet. The two spaces of indentation matter, because the file is in YAML format.
A portfolio on GitHub
- Profile README: create a public repository with exactly the same name as your username, for example asmith/asmith, with a README.md. Its contents appear at the top of your profile: a short introduction, what you work on and links to your best repositories.
- Pinned repositories: on your profile choose Customize your pins to show up to six repositories you are proud of.
- GitHub Pages: a free website made from a repository. In the repository's Settings › Pages, choose the branch (main) and folder to publish. A repository called your-username.github.io becomes your personal site at that address; other repositories publish at your-username.github.io/repository-name. Changes can take a few minutes to appear.
For a job application, a tidy profile with two or three well-documented analyses says more than a list of skills: an employer can open them and see how you work.
Automatic checks with GitHub Actions
GitHub Actions runs commands for you on GitHub's computers whenever something happens, for example every time you push. Scientists use it to run tests, check that a notebook still runs, or rebuild a report. A workflow is a YAML file in the folder .github/workflows/. This one checks out the code, installs Python and runs the tests on every push:
name: tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -r requirements.txt pytest
- run: pytestThe Actions tab shows each run with a green tick or a red cross, and the full log. For public repositories the standard machines are free. You do not need Actions for this course; it is enough to recognise one and know what it does.
Data, privacy and secrets
This is the most important part of the module. Git remembers everything: a file you delete in a later commit is still in the history, and anyone who clones a public repository gets that history.
| Never put on GitHub | Why | Instead |
|---|---|---|
| Patient or participant data, including pseudonymised data | Data protection law, ethics approvals and data access agreements | Keep it on approved, secure storage. Share code and synthetic or public example data |
| Passwords, API keys, tokens | Bots scan public repositories for keys within minutes | Keep them in a .env file listed in .gitignore, or in GitHub Actions secrets |
| Large raw data (FASTQ, BAM, images) | Files over 100 MB are refused, and repositories should stay small | Public archives (SRA/ENA, GEO, PRIDE), Zenodo or figshare, with the accession or DOI in your README |
| Anything you do not have the right to share | Copyright and licences | Link to the original source |
- GitHub's push protection, on by default for public repositories, blocks many kinds of keys when you push and tells you which file contains them.
- If you do push a key by mistake, revoke it at once with the service that issued it, then create a new one. Deleting the file is not enough.
- For files between 50 and 100 MB that truly belong with the code, Git LFS (Large File Storage) stores them separately, but archives are usually the better home for data.
Before you make a repository public
Read through every file, and the history, and ask: is there any personal data, any key, any data I am not allowed to share? Check .gitignore. When in doubt, keep it private and ask.
For LSMA projects, a marker must be able to open your link without signing in: that means a public repository containing only code, documentation and public or synthetic example data.
Judging someone else's tool before you trust it
- Licence: is there one, and does it allow your use?
- Activity: when was the last commit? Are issues answered?
- Documentation: does the README say how to install it, run it and cite it?
- Releases: are there versioned releases you can pin in your methods?
- Tests: does it run automatic checks (a green tick next to recent commits)?
- Stars show popularity, not correctness: a published paper or wide use in a field matters more.
Release and cite
This lesson
Add a CITATION.cff to lsma-practice with your own details, then publish release v1.0.0.
Check your answer
The sidebar shows Cite this repository and a release labelled v1.0.0 Latest. If you also connected Zenodo before publishing, a DOI appears on Zenodo within a few minutes.
Check for secrets
This lesson
Look through your repository and its history for anything that should not be public. Add .env and your data folder to .gitignore even if they do not exist yet.
Check your answer
Nothing personal, secret or large is tracked, and .gitignore protects you from adding it by accident later. This is a habit to repeat before every repository goes public.
Check your understanding
1. Why publish a release before you submit a paper or report?
2. You accidentally pushed an API key to a public repository. What is the first thing to do?
3. Where should 40 GB of raw FASTQ files from your project go?
Up next
GitHub project
Your portfolio repository