Skip to content

GitHub for Scientists

GitHub is a website that hosts Git repositories online. Think of it as the place your code lives when it is not sitting on your laptop, reachable by collaborators, reviewers, and the wider scientific community. This page covers the GitHub skills a scientist actually needs.

Sign in to GitHub and click the + button to create a new repository.

You need to choose between public and private:

  • Public repositories are visible to everyone. Use these for published papers and open-source tools. Public repos are free.
  • Private repositories are only visible to you and people you invite. Use these for unpublished work or sensitive analyses.

Give your repository a descriptive name like rnaseq-drug-response rather than project1. Add a short description so others know what the project does.

If you already have a local repository, create an empty GitHub repository. Leave the README, license, and .gitignore options unselected. This avoids separate initial commits when you connect the repositories.

If the GitHub repository already contains commits, clone it first. Add your project files inside that clone. Keep the original local repository until you confirm that its files and history are preserved.

Run the commands from your local repository directory. Replace the example username and repository name with your GitHub repository URL.

Terminal window
git remote add origin https://github.com/your-username/your-repo.git

This tells Git where to send your commits when you push. origin is just a name. It is the conventional label for your primary remote, and you will see it in almost every Git tutorial you read.

Inspect the saved remote URLs:

Terminal window
git remote -v

This command reads local configuration. It does not test authentication or access to GitHub. If origin already exists, inspect its URL before you change it.

Configure command-line authentication before your first push. The HTTPS example uses GitHub CLI, a credential helper, or a personal access token. Your GitHub account password does not authenticate a Git push. SSH uses a different remote URL and an SSH key. Follow GitHub’s authentication instructions for your chosen method.

The command below assumes your local branch is main and contains at least one commit. Check the branch with git branch --show-current. If its name differs, use that name in the push command.

Upload your local commits to GitHub with git push:

Terminal window
git push -u origin main

The -u flag sets origin main as the default upstream. After the first push, you can simply run:

Terminal window
git push

After the push succeeds, refresh the repository page and confirm that the latest commit appears. GitHub has the commits you pushed. Uncommitted files and ignored data still need separate backup.

Download changes from GitHub with git pull:

Terminal window
git pull

Use this when collaborators have pushed changes. Pull before you start a new task, after you commit or set aside local changes. Conflicts can still occur when both branches change the same content. Read Git’s message and resolve the conflict before you continue.

Download a complete copy of any public repository:

Terminal window
git clone https://github.com/nf-core/rnaseq.git

This creates a local directory with the full repository history. You can browse the code, run the scripts, and even modify them locally.

Every repository should have a README.md file. This is the front page that GitHub displays when someone visits your repo.

A good README for a scientific project includes:

  • What the project does. One or two sentences describing the analysis or tool.
  • How to run it. List the dependencies and provide the commands needed to reproduce results.
  • What data it needs. Describe the input data and where to get it.
  • Who to contact. Your name and email for questions.

Write the README in Markdown. GitHub renders it automatically.

Mark specific versions of your code with tags. This is critical for reproducibility.

Terminal window
git tag v1.0-paper
git push origin v1.0-paper

A tag gives a commit a readable name. Tags can be moved or deleted, so record the commit hash with the release. Archive the publication version for a stable citation. The Git tag documentation explains how tags reference repository objects.

On GitHub, go to the Releases page to create a formal release from a tag. You can attach supplementary files and write release notes.

Issues are a built-in task tracker. Use them to:

  • Record bugs you find in your analysis.
  • Track to-do items for your project.
  • Document decisions about methodology.

Even on a solo project, issues help you organize your work. Write a clear title and a brief description of the problem or task.

For private repositories, go to Settings > Collaborators and invite people by their GitHub username. They get read and write access to the repository.

Pull requests let you propose changes and get feedback before merging. The workflow is:

  1. Create a branch for your changes.
  2. Push the branch to GitHub.
  3. Open a pull request on GitHub.
  4. Your collaborator reviews the changes.
  5. Merge the pull request when approved.

Even in small teams, pull requests create a record of what changed and why. They also catch mistakes before code reaches the main branch.

A LICENSE file states the permissions and conditions for reuse. Choose terms you can grant for your own code, and retain the terms that apply to code from other authors.

The table summarizes selected conditions. Each linked license contains the full terms.

License Selected conditions
MIT Use, modification, and distribution are permitted. Copies or substantial portions must retain the copyright and permission notices.
Apache 2.0 Redistribution requires the license, change notices, retained relevant notices, and applicable NOTICE attribution. Its contributor patent grant has a defined scope and termination condition.
GPLv3 Private modifications need no public release. Distribution of covered modified source requires GPLv3 terms and notices. Distribution of object code also requires Corresponding Source under section 6.

These choices differ in notice, patent, and source distribution conditions. Compare those conditions with your project’s existing licenses before selecting one.

Check your target journal’s code availability requirements before submission. A tagged GitHub release identifies your code version, but the journal may also require an archive, license, data access statement, or reproduction instructions.

Best practices for publication:

  • Tag the exact version used to generate results in the paper.
  • Include a README with reproduction instructions.
  • Archive the repository on Zenodo. Zenodo creates a DOI for your repository, giving it a citable identifier that will not break if GitHub changes.
  • Reference both the GitHub URL and the Zenodo DOI in your paper.
  • Create repositories on GitHub to back up and share your code.
  • Push regularly to keep your work safe.
  • Write a README so others can understand and run your code.
  • Tag releases for reproducibility.
  • Add a license so others can legally reuse your work.
  • Use Zenodo to create DOIs for publication.
  • Pull requests enable code review even in small teams.

The GitHub authentication guide explains the difference between HTTPS and SSH access from the command line. Use it before the first push from a new computer.

The Zenodo software archive guide explains release creation and the checks for a processed record and its archival status. The Git tag manual explains tag references and replacement, which is why the publication record should also retain the commit identity.