Git Pre-Workshop
Workshop: Managing the Development Cycle with Git, GitHub, and GitHub Actions
by Nicholas Del Grosso, October 1st, 2025
Pre-Workshop Materials: Getting Started
This notebook is meant to help you get ready for Monday’s session. On Monday, we’ll be jumping into some of the aspects of Git
and GitHub
related to automated code quality checking and collaboration, both in toy examples and in real projects from your team:
- GitHub Pull Requests & Protected Branches to do GitHub Flow
- GitHub Remotes & Continuous Integration with GitHub Actions
- Commits with Git & using pre-commit to format and lint code with nbqa and ruff
The sections below have information on how to get a common computational environment set up for the session, and which commands and procedures would be helpful to be familiar with before coming to the session, to get the most out the unit. The commands below are terminal commands–if you are familiar with how to do the same tasks using the VSCode
graphical interface, that is also totally fine for our purposes.
Registration and Installation
Make sure you can log in to these online services:
-
GitHub
:- Note: The
GitHub
username and email does not have to match yourgit
username and email.
- Note: The
Make sure these programs are installed:
- Test the Installation works in the terminal:
git -v
- Confirm your name is set for commits:
git config user.name
- If not, run
git config --global user.name "<your name>"
- If not, run
- Confirm your email is set for commits:
git config user.email
- If not, run
git config --global user.email "<your email>"
- If not, run
- Test the Installation works in the terminal:
- Test the Installation works in the terminal:
uv self version
- Test the Installation works in the terminal:
Visual Studio Code (“VSCode”)
- Test the Installation works either:
- In the terminal:
code -v
- Through the standard app launcher.
- In the terminal:
- (optional) Install Useful VSCode Extensions:
- Test the Installation works either:
Refresh Your Skills
To prepare for the session, please look through each of the sections below and check the skills checklist and the reference tables. If those aspects seem familiar to you, you’re ready to go! If anything is unclear, please feel free to write to me (Nicholas Del Grosso) and ask questions at the session itself.
1. Linear Version Control With git
Skills Checklist
Read through each of the following statements about proficience around a given technical task. For any of the technical tasks listed below that you’re not confident with, please do the onboarding exercises in the sections below, as part of preparation for the workshop session.
- I can start a new git project.
- I can make commits for sets of files I’ve changed.
- I can view my git commit log.
- I can checkout past commits to view the files at that stage, and then checkout the latest commit to come back to the present state of the project.
- I can revert or stash uncommitted changes to get my project back to the last committed state.
How to Make Commits
Command | Description |
---|---|
git init | Initialize a new Git repository in the current directory |
git status | Show the status of changes in the working directory |
git add <file> | Stage “file” for commit |
git add . | Stage all modified and new files |
git commit -m "<message>" | Commit staged files with a message |
git commit -am "Commit message" | Stage and commit all modified files in one step |
git log | View the full commit history of the repository |
git diff | Compare the working directory with the last commit |
Try it Out:
a. Make a fresh project with some history:
- Make a new directory and turn it into a git repository.
- Add a new file with some “Hello” text and and commit it.
- Add the line “Bye” to the text file and commit that change. Check the diff log to see that git noticed that “bye” was added.
- Add a second file called “numbers.txt” and commit it.
How to Rewind & Undo
Command | Description |
---|---|
git checkout HEAD^1 | “Rewind one step”: Update the working directory to match the latest commit. |
git checkout <commit> | “Jump to a specific commit”: Update the working directory to match the given commit. |
git checkout . | “Fast Forward”: Update the working directory to match the latest commit. |
git reset <file> | Unstage “file”, before committing. |
git reset --soft <commit> | Rewind the history to commit hash “commit”, keeping all changes after in the stage. |
git reset --hard <commit> | Rewind the history to commit hash “commit”, dumping all commits made afterward. (Note: Dangerous in shared repos) |
git revert <commit> | Make a new commit that makes the repo look just like it did at “commit” (Note: Great in shared repos) |
Try it Out:
b. Play with the history of the project.
- Rewind back to the first commit using “checkout”, then go back to the latest commit. (note: the log will help identify the commit hash)
- Do a revert to make the project look like it did at the first commit.
- Rewind back to the previous commit to see that the history hasn’t been lost–the second file that was created is still in the history, it just got deleted again.
- Change the history by doing a
hard reset
: bring it back to the state at the first commit. Verify that thie history is now lost–there is really only one commit now. Whoops!
2. Branched Version Control with git
Skills Checklist
Read through each of the following statements about proficience around a given technical task. For any of the technical tasks listed below that you’re not confident with, please do the onboarding exercises in the sections below, as part of preparation for the workshop session.
- I can check the name of the current git branch I’m on, and see the names of the branches in the repo.
- I can make new git branches, in order to experiment with a new feature or develop something new.
- I can commit to the current branch.
- I can switch between branches, to jump between different versions of my project.
- I can merge the commits from one branch onto another.
- I can delete branches I don’t want any more, whether I’ve merged them or not.
How to Work with Branches
Command | Description |
---|---|
git branch | List the branches in the repo (active one has a star by it) |
git branch <name> | Make a new branch from the current commit, named |
git switch <name> | Switch the HEAD to the specified branch. |
git merge <name> | Merge the commits from the branch into the current commit. |
git rebase <name> | Put the commits from the current branch onto the end of branch . |
git branch -d <name> | Delete a branch and all the commits with it. |
git branch -D <name> | Delete a branch and all the commits with it, even if they aren’t merged somewhere else already. |
Try it Out:
c. Make some new branches on an existing repo (check section above if you need to make a new repo):
- Make a new branch called
new
- Switch to it.
- Make a new text file called
snake.py
with the textprint("Hsss...")
and commit it. - Switch back to your previous branch, and verify the
snake.py
is gone. - Switch back to the
new
branch, and getsnake.py
back! - Merge the new branch into the previous branch. Now
snake.py
is in both branches! - Delete the
new branch
–it’s done its job.
3. Remote Repo Syncing between git
and GitHub
Skills Checklist
Read through each of the following statements about proficience around a given technical task. For any of the technical tasks listed below that you’re not confident with, please do the onboarding exercises in the sections below, as part of preparation for the workshop session.
- I can clone an existing
GitHub
repo to my local computer and build onto thegit
commit history. - I can fetch the latest info about branches and commits from
GitHub
to my localgit
repo. - I can pull the latest commits from a given branch on
GitHub
into my current localgit
branch. - I can make a new repo on
GitHub
’s website and push my localgit
repo to it.
How to Sync with Remote Repos
Command | Description |
---|---|
git clone <url> <path> | Copy the repo at “url” to your local machine at “path” |
git remote -v | List the names of the remote repos, and their urls. |
git remote add <name> <url> | Add a new remote repo. |
git fetch <name> | Download the repo metadata and commits from the “name” remote repo. Note: doesn’t affect local branches. |
git merge <name> | Merge the commits from the branch “branch” (which could be a remote branch) into the current branch. |
git pull <remote> <branch> | a “fetch & merge” shortcut: Fetch and merge Download the commits from the “remote” remote’s “branch” branch. |
git push <remote> <branch> | Upload the current branch to “remote” “branch” |
git remote remove <name> | Remove a remote repo. Note: this just deletes the record from the local repo, it doesn’t actually delete the remote repo and its data. It’s useful to do this when you’ve made a typo, for example. |
Try it out:
- Make a new repo on GitHub, letting it add a README file and such to get the commit history started.
- Clone the repo to your local machine (Note: if it’s a private repo, you’ll need either to put your password (the https:// link) or have your public ssh key available on Github (“Settings” -> “SSH and GPG Keys” -> “New SSH Key”), then copy-paste the contents from the public file made after running
ssh-keygen
on your machine.) - Check that your local repo knows about your github repo.
- Modify the Readme file in the repo on your local machine, and commit it.
- Push the committed change to the remote repo, and refresh the webpage to see the changes.
- Use the “edit” feature in the web page to modify the Readme file in the Github website and make the commit using your web browser.
- Pull the remote change down to your local repo.