Git for Everyone

An Introduction to Version Control and GitHub

Jared Frazier

Modelling of Atmospheric Processes Department
Leibniz Institute of Atmospheric Physics

2026-03-13

Precursors

Slides

Hands-On Materials

Behavior

  • Ask questions whenever they arise!
  • I will make mistakes, though I’ll try my best not to.

Structure

Objectives

  • Motivate version control and code collaboration tools.
  • Introduce Git commands (plus mental models).
  • Introduce GitHub (branches, issues, pull requests/merging).

Style

  • Mix teaching and practical exercises.
  • Ideally, you should have a computer with a text editor/IDE, terminal, and browser open.

Setup

Git

Windows

  • If you are on Windows, select one of the standalone installers (most likely x64) from install on Windows. The default settings are fine.

Linux + macOS

GitHub

Intro to Git

What is Git

  • A version control system developed by Linus Torvalds (creator of Linux).
  • Record the history of file changes over time.
  • For each revision/snapshot (aka commit) tell:
    Who changed what, when, and why.
  • Intended for text files and small datasets (<100 MB).
  • Fundamentally not for large file storage, see git-lfs, dvc, etc instead.

Why You Should Use Git

“Piled Higher and Deeper”, www.phdcomics.com
  • Wednesday 22 Jan 2026 11:45 viz_my_data.py
  • Thursday 23 Jan 2026 14:23 viz_my_data_v1.py
  • Friday 24 Jan 2026 23:45 viz_my_data_final_v2_stable.py

Git Workflow: A Primer

Sections of a Git project (adapted from Pro Git).

Basic Commands

  • git init
    • Create an empty Git repository.
  • git clone <repo url> [<dir>]
    • Clone a repo into a new directory.
$ # Alternatively, replace url with your forked url
$ git clone git@github.com:jfdev001/git-for-everyone-miniweather.git
Cloning into 'git-for-everyone-miniweather'...
remote: Enumerating objects: 2200, done.
remote: Counting objects: 100% (2200/2200), done.
remote: Compressing objects: 100% (618/618), done.
remote: Total 2200 (delta 1594), reused 2176 (delta 1574), pack-reused 0 (from 0)
Receiving objects: 100% (2200/2200), 8.44 MiB | 379.00 KiB/s, done.
Resolving deltas: 100% (1594/1594), done.

Basic Commands

  • git init
    • Create an empty Git repository.
  • git add <filepath>
    • Stage changes you want to record.
  • git clone <repo url> [<dir>]
    • Clone a repo into a new directory.
  • git status
    • List files Git has (not) added.
$ cd git-for-everyone-miniweather
$ touch NEW_FILE.txt
$ git add ./
$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   NEW_FILE.txt

Basic Commands

  • git init
    • Create an empty Git repository.
  • git add <filepath>
    • Stage changes you want to record.
  • git commit [-m "short message here"]
    • Commit changes to history with message.
$ git commit -m "add a new file"
[main 8f07f0c] add a new file
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 NEW_FILE.txt
  • git clone <repo url> [<dir>]
    • Clone a repo into a new directory.
  • git status
    • List files Git has (not) added.
  • git log
    • Show Git history (i.e., commits).
$ git log 
commit 8f07f0cacba3518219d5630d8a95b291ff4ebe3e (HEAD -> main)
Author: Jared Frazier <cscidev001@gmail.com>
Date:   Thu Mar 12 10:45:47 2026 +0100

    add a new file

commit 9584a0cf4f360a50e0981debc7e0256d0e39aadb (origin/main, origin/HEAD)
Author: Jared Frazier <frazier@iap-kborn.de>
Date:   Wed Mar 11 15:39:32 2026 +0100

    add docker pull instructions

Basic Commands

  • git init
    • Create an empty Git repository.
  • git add <filepath>
    • Stage changes you want to record.
  • git commit [-m "short message here"]
    • Commit changes to history with message.
  • git push <remote> <branch>
    • Send local changes to remote repo.
  • git clone <repo url> [<dir>]
    • Clone a repo into a new directory.
  • git status
    • List files Git has (not) added.
  • git log
    • Show Git history (i.e., commits).
$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 274 bytes | 274.00 KiB/s, done.
Total 3 (delta 1), reused 1 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:jfdev001/git-for-everyone-miniweather.git
   9584a0c..8f07f0c  main -> main

Exercise

A colleague has written a Fortran application that simulates fluid-dynamic flows:

If you have an account, then fork (upper right corner) the repository and clone your fork.

If you do not have an account, just clone my repository.

  • git clone <repo url>
  • git add
  • git status
  • git commit [-m "your message here"]
  • git push
    • Won’t work if you didn’t fork
  • git log
  • If there are Python scripts, are there dependencies? (hint: add requirements.txt)
  • Is there a script in README.md that could be moved into a new file (hint: bottom of README.md)?
  • PnetCDF is a dependency, what if this generates large files? (hint: patterns in .gitignore aren’t added to Git history)
  • Ask questions if you’re lost!

How does Git work

  • Each time you commit work, Git stores it as a diff.
    • Shows specific lines of a file and how they are changed (+/-)
    • This is what the command git diff shows before staging, if you want. to see the diffs for staged (i.e., after git add) files, do git diff --staged.
  • diffs are stored in a tree, by reconstructing diffs you can reconstruct files, and thus the “snapshot” of your files at a particular state of development.


$ echo "This is some new text" >> NEW_FILE.txt
$ git diff 
diff --git a/NEW_FILE.txt b/NEW_FILE.txt
index e69de29..10ee18b 100644
--- a/NEW_FILE.txt
+++ b/NEW_FILE.txt
@@ -0,0 +1 @@
+This is some new text

Git Workflow: Revisited

Sections of a Git project (adapted from Pro Git).

Intro to GitHub

What is GitHub

  • Stores Git repositories online
  • Helps developers collaborate on code
  • Provides tools for project management

Issues

  • Creating issues can be useful for keeping track of work.
  • Subsequent commits (in pull requests, more on this later) can reference a particular issue(s).
  • Generally you open issues in main repository, but opening them in your fork is fine.

Exercise

  • What sort of improvements could you think of adding to the miniweather simulation?
  • Open an issue in either your fork or in my repository if you don’t have a fork!
  • Hints:
    • Different spatial discretization schemes?
    • CUDA implementation?
    • Different governing equations?

Branches

  • We have only used the main branch for all commits.
  • A more standard approach is to create a branch dedicated to a particular feature or set of changes, then you merge back into main when completed.
  • git branch <branch name>
    • Create new branch from current branch.
  • git checkout <branch name>
    • Move to different branch.
  • git merge <branch name>
    • Tie the target branch back into the current branch.
    • e.g., git merge feature

Branches

Branches facilitate concurrent feature development and project organization.

Exercise

  • We want to add a script that cleans/deletes the build_output directory.
  • Create a branch and add a script (Bash, Python, etc.) to miniweather/build/ called clean_build_output that does this for us.
  • Make sure to git add and then commit your changes.
  • push your new branch to your remote repository.
  • Switch back the main branch and inspect the git log and git branchs.
  • git branch [<branch name>]
  • git checkout <branch name>
  • git add
  • git commit
  • git push -u origin <new branch name>

Pull Requests

  • A graphical way to merge branches into main on GitHub.
  • Can be linked back to GitHub issues, thus improving development organization.
  • Method of tracking progress (open a PR after first push) and discussion.
  • Should include description of what you’ve done and why you did it.

Exercise

From branch(es) you pushed in the previous exercise open a pull request to either:

  • The main branch of my repository.
  • The main branch of your fork.

Then try and merge what you’ve done.

If there are merge conflicts try to resolve them.

Git Workflow: The Finale

Sections of a Git project (adapted from Pro Git).

Summary

  • Git is not just a series of backups, it facilitates collaborativesoftware development and clean version tracking.
  • Inspect the status and commit history of a repository.
  • Use branches for each additional feature/improvement you work on.
  • GitHub (and GitLab) provide complementary features to Git:
    • Remote copy of your local Git repository.
    • Issues.
    • Pull requests.
    • Graphical branch merging.

A Warning

Thanks!

Appendix

SSH Keys with GitHub

  • This allows you to clone URLs that look like git@github.com[<repo>].git
  • It also allows you to push to your own repositories.
  • In Git Bash on Windows or a terminal on Linux/macOS:
# It's more secure to passphrase protect your SSH key, but up to you...
# for an empty passphrase, just hit enter after calling ssh-keygen
ssh-keygen -t ed25519 -f ~/.ssh/id_github_ed25519

cat ~/.ssh/id_github_ed25519.pub
# ^^ copy the above public key
# GitHub.com > Top Right Corner > Settings > SSH & GPG Keys > New SSH key
# then paste the public key above into the form on GitHub

# there are cleaner ways to do this, but activate your ssh agent like so:
echo 'eval $(ssh-agent -s)' >> ~/.bash_profile
echo "ssh-add ~/.ssh/id_github_ed25519" >> ~/.bash_profile
source ~/.bash_profile

# verify that you can connect to GitHub
ssh -T git@github.com