LSMA

LONDON SCHOOL OF MULTIOMICS & AI

LSMA

LONDON SCHOOL OF MULTIOMICS & AI

Free course

Free course

0 of 79 lessons

GitHub essentials · Lesson 4 of 4

Module 3 · The command line · GitHub essentials

Sharing science on GitHub

Sharing science on GitHub

Sharing science on GitHub

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.

⏱ 7 min readModule 3 · The command line · GitHub essentialsFree
Lesson at a glance7 steps · about 7 min
  1. Run code in the browser
  2. Freeze the version behind a result: releases
  3. Make your code citable
  4. A portfolio on GitHub
  5. Automatic checks with GitHub Actions
  6. Data, privacy and secrets
  7. Judging someone else's tool before you trust it

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.

Study guide for this moduleThe GitHub study guide explains every step in this module in more detail, with a command cheat sheet, a glossary and fixes for common problems. Keep it open beside the lessons.
lsma-github-study-guide.pdfGitHub essentials: the complete study guide (PDF)

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.

  1. On the repository page choose Releases in the sidebar, then Draft a new release.
  2. Under Choose a tag, type v1.0.0 and choose Create new tag.
  3. 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.
  4. 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.
CITATION.cff
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:

.github/workflows/tests.yml
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: pytest

The 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 GitHubWhyInstead
Patient or participant data, including pseudonymised dataData protection law, ethics approvals and data access agreementsKeep it on approved, secure storage. Share code and synthetic or public example data
Passwords, API keys, tokensBots scan public repositories for keys within minutesKeep 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 smallPublic archives (SRA/ENA, GEO, PRIDE), Zenodo or figshare, with the accession or DOI in your README
Anything you do not have the right to shareCopyright and licencesLink 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.
1

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.

2

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

Ask LSMA