GitHub Introduction

GEN242: Data Analysis in Genome Biology

Thomas Girke

2026-04-07

Overview

Topics covered in this tutorial:

  • What are Git and GitHub?
  • Installing Git
  • Git basics from the command-line
  • GitHub basics from the command-line
  • SSH Key authentication for private repos
  • Using GitHub from RStudio
  • Online file upload workflow
  • Viewing static HTML files on GitHub Pages

Note

This class makes heavy use of GitHub. Homework and course projects are submitted and graded via GitHub Classroom.

GitHub in GEN242

  • Homework assignments are submitted and graded on GitHub Classroom
  • Course projects use private GitHub repositories — one per project, shared within each team
  • Each student needs a personal GitHub accountgithub.com/personal
  • GitHub provides unlimited free public repositories
  • Via GitHub Education students can get extended free private repos
  • New to GitHub? Start with the Hello World quick guide

What are Git and GitHub?

Git — local version control

  • Tracks changes in files over time
  • Works locally on your machine
  • Enables branching, merging, full history
  • Free and open source

GitHub — remote collaboration

  • Online hosting service built on Git
  • Stores repositories in the cloud
  • Adds issues, pull requests, forks
  • Enables code sharing and review

Tip

Git + GitHub together = local version control synced with a remote shared repository.

Installing Git

OS Command / Method
Windows Installer from git-scm.com
macOS brew install git or Xcode Command Line Tools
Linux (Debian/Ubuntu) sudo apt install git
Linux (Fedora/RHEL) sudo dnf install git

Note

When using Git from RStudio, set the path to the Git executable under:
Tools → Global Options → Git/SVN

Practice in the browser (no install needed): try.github.io

Git Basics — Core Commands

Get help

git <command> --help

Initialize a new repository

mkdir my_dir
cd my_dir
git init          # creates a hidden .git/ folder to track history

Stage files for commit

git add myfile.txt     # stage a specific file
git add .              # stage all changes in current directory (recommended for daily use)
git add -A :/          # stage all changes in entire repo regardless of working directory
Command Stages Best for
git add myfile.txt One file only Selective, careful commits
git add . All changes under current directory Daily use — simple and intuitive
git add -A :/ All changes in entire repo Working inside a subdirectory

For most workflows git add . is sufficient. Use git add -A :/ if you are working inside a subdirectory and want to be sure nothing elsewhere in the repo is missed.

Tip

List files to ignore (temp files, outputs) in a .gitignore file at the repository root. Regular expressions are supported — see GitHub docs.

Commit a snapshot

git commit -am "describe your changes"
# -a  stages all tracked modified files
# -m  sets the commit message inline

GitHub Basics — Remote Workflow

Create the repository on GitHub first (leave README/license/.gitignore unchecked), then:

git remote add origin git@github.com:<user_name>/<repos_name>.git

Warning

Do not initialize the GitHub repo with any files — that causes merge conflicts on the first push.

2. Push local commits to GitHub

git push          # first push; after this, just: git push

3. Clone an existing repository

git clone git@github.com:<user_name>/<repos_name>.git

4. Daily workflow

git pull                            # sync before you start editing
# ... make your changes ...
git commit -am "describe changes"   # commit locally
git push                            # send to GitHub

SSH Keys for Private Repositories

Private GitHub repositories (like your GEN242 homework repos) require SSH Key authentication. Password-based access is no longer supported by GitHub.

Why SSH Keys?

  • Secure, password-less authentication
  • One key pair generated per computer (laptop, HPCC cluster — each needs its own)
  • Public key lives on GitHub; private key stays on your machine

Setup steps

Step 1 — Generate a key pair on your machine (or on the HPCC cluster):

ssh-keygen -t ed25519 -C "your_email@example.com"

Step 2 — Display the public key and copy it:

cat ~/.ssh/id_ed25519.pub

Step 3 — Add it to GitHub:
Settings → SSH and GPG keys → New SSH key → paste → Save

Tip

For the HPCC cluster: generate the key pair on the cluster and upload ~/.ssh/id_rsa.pub to GitHub. See HPCC SSH Key docs.

SSH Key Authentication Flow

SSH Key Workflow

Each computer that needs to push/pull from a private repo requires its own key pair. Upload each computer’s public key to GitHub separately.

Exercise — Full Git Workflow

Run this after creating your GitHub repository (see HW01 instructions):

# Clone the remote repository to your machine
git clone git@github.com:<user_or_org>/<repo_name>
cd <repo_name>

# Sync any remote changes
git pull

# Create a test file, stage, commit, and push
touch test
git add .              # or: git add test  to stage only this file
git commit -am "add test file"
git push

# Now edit 'test' directly on GitHub online, then pull the change back:
git pull

Online File Upload

For users not yet comfortable with the command-line, GitHub supports browser-based uploads:

  1. On your repository page click Add fileUpload files

  2. In the file path field, type a subdirectory path and placeholder filename:

    Homework/HW1/dummy.txt
  3. Upload your actual file to the newly created directory

  4. Delete dummy.txt afterward

Note

GitHub does not display empty directories — the placeholder file trick creates the folder structure first so your real file has somewhere to land.

GitHub from RStudio

One-time setup

  1. Install Git — git-scm.com
  2. Tell RStudio where Git is: Tools → Global Options → Git/SVN
  3. (Optional) Configure SSH Keys from within RStudio — see Happy Git with R

Clone a repository into RStudio

File → New Project → Version Control → Git → paste repository URL

Commit and push changes

Tools → Version Control → Commit

  • Check the files you want to stage in the Staging Area
  • Write a commit message in the box
  • Click Commit, then Push

Tip

Useful RStudio keyboard shortcuts: support.rstudio.com

Viewing HTML Files on GitHub Pages

By default GitHub renders raw HTML source, not the page. Enable GitHub Pages to serve rendered HTML:

  1. Make your repository public
  2. Go to Settings → Pages
  3. Under Source select Deploy from a branch
  4. Choose branch main, click Save
  5. Wait for the URL — then append your HTML file path to view it

Note

The GEN242 course site itself is hosted this way via GitHub Pages.
Example repo: github.com/tgirke/View_HTML_on_GitHub

Summary

Action Command
Initialize repo git init
Stage files git add . or git add -A :/
Commit changes git commit -am "message"
Link to remote git remote add origin <url>
Push to GitHub git push
Pull from GitHub git pull
Clone a repo git clone <url>

Daily workflow

git pull                        # always sync first
# ... edit your files ...
git commit -am "your message"   # commit locally
git push                        # push to GitHub

Next: T2 — Linux & HPCC Cluster