This is written as an instructor script you can run live. It starts with SSH verification, then does a quick local Git demo, then transitions into the pair labs.
Ask students to open a terminal in a working directory where they can create a new folder. Quick sanity checks:
git --version
ssh -VIf Git is missing, have them install Git and restart their terminal.
ssh -T git@github.comExpected outcomes:
- If it prints a greeting and mentions successful authentication, they are good.
- If it asks to confirm a host fingerprint, type
yes. - If it says permission denied, continue below.
- Check for an existing key:
ls -al ~/.sshLook for id_ed25519 and id_ed25519.pub (or id_rsa / id_rsa.pub).
2) If no key exists, generate one:
ssh-keygen -t ed25519 -C "your_email@example.com"Accept defaults. Use a passphrase if you want, but warn that it adds prompts unless they use a keychain. 3) Start agent and add the key:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519- Copy the public key and add it to GitHub macOS:
pbcopy < ~/.ssh/id_ed25519.pubLinux:
xclip -selection clipboard < ~/.ssh/id_ed25519.pubWindows Git Bash:
cat ~/.ssh/id_ed25519.pubThen GitHub: Settings → SSH and GPG keys → New SSH key → paste. 5) Re-test:
ssh -T git@github.comOptional debugging (when someone is still stuck):
ssh -vT git@github.comSay this out loud:
- Clone: downloads a repo to your machine.
- Fork: makes a copy on GitHub under your account. Two common scenarios:
- You have write access to the repo (class repo, your own repo): clone it directly.
- You do not have write access (open source, partner repo): fork on GitHub, then clone your fork.
- Go to:
https://github.com/Stat386-Winter-2026/Git_demo. - Determine whether you should clone directly or fork the repo.
- Walk through the fork + clone steps:
- Click Fork in GitHub, keep the default settings.
- Copy the SSH URL from your fork (not the instructor repo).
- In the terminal:
git clone git@github.com:<student-username>/Git-demo.git
cd Git-demo
git remote -voriginnow points to your fork. If you need the upstream link, add it withgit remote add upstream git@github.com:Stat386-Winter-2026/Git_demo.git.- You can still pull upstream changes later with
git fetch upstream && git merge upstream/main.
First navigate to a working directory you want to create a folder in and then:
mkdir git_demo
cd git_demo
git initExplain: git init creates the hidden .git directory, the local database.
Create hello.py:
print('Hello, Git!')Then:
git status
git add hello.py
git commit -m "Initial commit: add hello.py"Append:
print('Learning version control')Then:
git status
git diff
git add hello.py
git commit -m "Add learning message"git log --onelineOptional (more visual):
git log --oneline --graph --allCopy the first commit hash from git log --oneline (the older one), then:
cat hello.py
git checkout <OLD_COMMIT_HASH> -- hello.py
cat hello.pyBring it back to the latest:
git checkout <MOST_RECENT_COMMIT_HASH> -- hello.py
cat hello.pyprintf "*.log\n" > .gitignore
echo "temp" > temp.log
git statusExplain: ignored files do not show up as untracked, which protects you when using
git add ..
git checkout -b featureAdd another line to hello.py:
print('Working on a new feature')Commit and show graph:
git add hello.py
git commit -m "Add feature print"
git log --oneline --graph --allMerge into main:
cat hello.py
git checkout master
cat hello.py
git merge featureCreate a new branch to simulate a conflict.
git checkout -b test_merge
git checkout masterIn master, change the last line of hello.py to:
print('Working on an old feature')git add hello.py
git commit -m "Modify feature line in master"
git checkout test_mergeOn test_merge, change the last line of hello.py to:
print('Working on an exciting feature')touch testing.txt
git add .
git commit -m "Modify feature line in test_merge"
git checkout master
git merge test_mergeThis will produce a conflict. Let's explore.
cat hello.py
git status
ls -alHere is how to abort the merge:
git merge --abort
git status
ls -alNow, let's try resolving it. Repeat the steps to create the conflict, then:
git merge test_mergeNow let's resolve it by editing hello.py to the desired final state. After
editing:
git add hello.py
git commit -m "Resolve merge conflict between master and test_merge"
git log --oneline --graph --allUse the provided notebook instructions in CLass Lab - Pull Requests.
Use the provided notebook instructions in CLass Lab - Conflicts.
- Conflicts happen when Git cannot safely auto-merge.
- The conflict markers show two competing versions.
- The resolution is just: edit to the correct final file, stage, commit.
- Forgetting to
git pullbefore merging - Resolving conflict in GitHub UI but not pulling locally
- Leaving conflict markers in the file
Exit ticket prompts:
- Explain clone vs fork in one sentence.
- Paste the first line of
ssh -T git@github.com. - What caused a conflict today and what did you do to resolve it?