LSMA

LONDON SCHOOL OF MULTIOMICS & AI

LSMA

LONDON SCHOOL OF MULTIOMICS & AI

Free course

Free course

0 of 31 lessons

GitHub essentials · Lesson 1 of 4

Module 2 · Statistics · GitHub essentials

Your GitHub account and first repository

Your GitHub account and first repository

Your GitHub account and first repository

Create a GitHub account and keep it safe, make your first repository with a README, a licence and a .gitignore, and add and edit files in the browser without installing anything.

⏱ 9 min readModule 2 · Statistics · GitHub essentialsFree
Lesson at a glance7 steps · about 9 min
  1. Git and GitHub in one picture
  2. Create your account
  3. Your profile in two minutes
  4. Create your first repository
  5. A tour of a repository page
  6. Write a good README
  7. Add files without installing anything

You have written R scripts and analyses in this course. This short module shows how to keep them safe, share them and work on them with others, using git and GitHub. It prepares you for A reproducible workflow, which uses git again.

Git and GitHub are not the same thing. Git is a program on your computer that records the history of a folder: every saved version of every file, who changed it and why. GitHub is a website that keeps a copy of that history online, so it is backed up, you can share it with a link, and other people can work on it with you.

By the end of this lesson you will have a GitHub account, a first repository with a README, and you will know how to add and edit files without installing anything.

Git and GitHub in one picture

  • Repository (often shortened to repo): a project folder whose history is tracked. On GitHub, each repository has its own page and address, such as github.com/your-name/rnaseq-practice.
  • Commit: a saved snapshot of the files, with a short message saying what changed.
  • Branch: a line of history. Every repository starts with one, usually called main.
  • Local means the copy on your computer; remote means the copy on GitHub. You push to send your commits up, and pull to bring other people's commits down.
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)

Key point

You can use GitHub without ever typing a git command: the website lets you create files, upload them and edit them. The command line and GitHub Desktop become useful once you work on files on your own computer, which is Lesson 2.

Create your account

  1. Go to github.com and choose Sign up.
  2. Enter an email address you will keep for years. A personal address is safer than a university or work address that you may lose when you move. You can add more email addresses later.
  3. Choose a password. Use a password manager, and do not reuse a password from another site.
  4. Choose your username. It becomes part of every link you share, so keep it professional: your name, or a short version of it, works well (for example asmith or alex-smith-bio). Avoid jokes, years of birth and long strings of numbers. You can change it later, but old links then stop pointing to you.
  5. Follow the steps to verify that you are a person and to confirm your email address with the code GitHub sends you.
  6. When GitHub asks about plans, the free plan is all you need for this course: GitHub Free includes unlimited public and private repositories.

Turn on two-factor authentication

GitHub requires two-factor authentication (2FA) for accounts that contribute code. It means that signing in needs your password and a second proof, so a stolen password alone is not enough. Set it up straight away under Settings › Password and authentication.

  • The most common method is an authenticator app on your phone (for example Google Authenticator, Microsoft Authenticator or 1Password), which shows a six-digit code that changes every 30 seconds.
  • You can also use a passkey or a hardware security key, the GitHub Mobile app, or text messages.
  • GitHub gives you recovery codes. Download them and keep them somewhere safe, away from your phone. If you lose your phone and your recovery codes, GitHub Support cannot give you your account back.

Free extras for students and teachers

If you are a student, apply for the GitHub Student Developer Pack at education.github.com. Once GitHub has verified that you study, it unlocks offers from GitHub and partner companies, which have included extra GitHub Codespaces time and GitHub Copilot, GitHub's AI coding assistant. Check the pack page for the current list, because it changes. Teachers can apply for the teacher benefits on the same site.

Your profile in two minutes

Your profile page, github.com/your-username, is what people see when you share your work. Under Settings › Public profile, add your name, a photo, a one-line bio (for example Biomedical scientist learning bioinformatics) and, if you wish, a link to LinkedIn or a personal page. Lesson 4 shows how to add a profile README, a short introduction that appears at the top of your profile.

Create your first repository

Choose the + menu at the top right of any GitHub page, then New repository. The form asks for:

FieldWhat to enterWhy
OwnerYour accountLater you may also own repositories through an organisation, such as a lab.
Repository namelsma-practiceShort, lower-case, words joined by hyphens. Letters, numbers, hyphens, dots and underscores only. The name becomes part of the address.
DescriptionPractice repository for the LSMA free courseOne line that says what the project is. It appears on the repository page and in search results.
VisibilityPublic for this practicePublic repositories can be seen by anyone, which is what you need for sharing work. Private ones are visible only to you and the people you invite.
Add a READMETurn it onThe README is the front page of the repository. Starting with one also makes the repository ready to clone straight away.
.gitignoreChoose the template for RA list of files git should never track, such as caches and temporary files. Lesson 2 explains it.
LicenceMIT LicenseSays what others may do with your code. Without a licence, nobody else is legally allowed to reuse it. MIT is short and permissive: anyone can reuse the code if they keep your copyright notice.

Then choose Create repository. You now have a page with your README shown below the list of files, and a history with one commit in it.

Public or private?

Make a repository public when you want to share it, for example to show your work to an employer or to submit an LSMA project link. Make it private for anything unfinished, personal or confidential. You can switch later under Settings › General › Danger Zone.

Whatever the visibility, never put patient data, personal data, passwords or API keys in a repository. Once something has been pushed, it stays in the history even if you delete the file later. Lesson 4 covers this in detail.

A tour of a repository page

  • Code tab: the files, with the README shown underneath. The green Code button gives the address for cloning and a Download ZIP option.
  • Commits (the clock icon with a number, above the file list): the full history. Each commit shows who made it, when, and the message.
  • Issues: a to-do list and place for bug reports. Pull requests: proposed changes waiting to be reviewed (Lesson 3).
  • Settings: name, visibility, collaborators, GitHub Pages and more. Only owners see it.
  • The right-hand sidebar: the description, the licence, and later releases and the Cite this repository link (Lesson 4).

Write a good README

A README is written in Markdown, a simple way to format text with ordinary characters. GitHub turns it into a formatted page. Open README.md, choose the pencil icon (Edit this file), and replace the text with something like this:

README.md
# LSMA practice

Practice repository for the LSMA free course.

## What is here

- `analysis/` holds my scripts
- `results/` holds the figures they make

## How to run it

1. Install the packages listed in `requirements.txt`
2. Run `python analysis/summary.py`

Author: Alex Smith. Licence: MIT.
  • A line starting with # is a heading; ## is a smaller heading.
  • Lines starting with - make a bullet list; 1. makes a numbered list.
  • Text between backticks, such as `analysis/`, appears in code font.
  • Use the Preview tab to see the result before you save.

To save, choose Commit changes, write a short message such as Describe the repository in the README, keep Commit directly to the main branch, and confirm. That creates your second commit.

Add files without installing anything

  1. On the repository page, choose Add file › Upload files.
  2. Drag files or a whole folder onto the page, or choose them from your computer.
  3. Write a commit message saying what you added, for example Add first analysis script.
  4. Commit the upload.

To create a file in a folder, choose Add file › Create new file and type the folder name followed by a slash in the name box, for example analysis/notes.md. GitHub creates the folder for you.

The website accepts files up to 25 MB each, and up to 100 files at a time. Larger files need the command line, and anything over 100 MB is refused by GitHub: data that large belongs in a data archive, not in a repository (Lesson 4).

Practise on our repository

MultiOmics Intelligence, the company behind LSMA, has made a practice repository for this module: github.com/MultiOmics-Intelligence/lsma-github-practice. It is a template: choose Use this template to make your own copy, with example data, a script in Python and in R, and a six-step task that follows these lessons.

Give it a Star and follow MultiOmics-Intelligence on GitHub to see new LSMA material as it appears.

1

Make your repository

This lesson

Create lsma-practice as above: public, with a README, a .gitignore template and the MIT licence. Then edit the README so it says what the repository is for, and upload one small file you have written in this course.

Check your answer

Your repository page should list three files (README.md, .gitignore, LICENSE) plus the one you uploaded, show your edited README underneath, and say MIT license in the sidebar. The commit history should show at least three commits: the initial commit, your README edit and your upload.

2

Find your way round

This lesson

Open the commit history of your repository. Which commit changed the README, and what exactly did it change?

Check your answer

Choose the clock icon above the file list, then the commit with your README message. GitHub shows the change as a diff: removed lines in red with a minus sign, added lines in green with a plus sign. That is how you will review every change from now on.

Check your understanding

1. What is the difference between git and GitHub?

2. Which file is the front page of a repository, shown under the list of files?

3. You lose your phone with your authenticator app. What gets you back into your GitHub account?

Up next

GitHub 2

GitHub: working from your computer

Ask LSMA