Version Control and Collaborative Workflows
Fall 2026
1
Reminder of what we did last week
Today’s Agenda
3
Today’s Agenda
4
Discussion Questions
When you clone a repository what happens? What files are downloaded from the origin?
What commands do you issue to put one of your own local directories under version control? After issuing that command, what happens, specifically?
What data structures does git use?
Git uses three core object types:
Blobs – A blob stores the actual contents of a file at each commit. Each time you commit a file, a new blob is created that stores the entire contents of the new file (even if you just change one line).
Trees or Graphs– A tree is a snapshot of the directory structure of your repo at a particular point in time. Remembers things like file names, what file is stored where, permissions, etc. A tree has pointers to the current version of the blob at each point in time.
Commits – A commit contains metadata (e.g., author, timestamp, commit message) and a pointer to a single tree object that represents the state of the project at the time of the commit.
Tl;dr Data Structure Summary
Today’s Agenda
10
Collaborative git workflows
When you start collaborating with other people, the workflow gets more complex. A few other concepts to introduce here:
11
Branching
Branches allow you to create new features (often experimental) without altering the main branch (where the authoritative version of the code lives).
Important ideas:
12
Branch Commands Using git
13
git checkout -b my-new-branch | Creates a new branch |
git branch | Tells you which branch you’re on |
git checkout main | Switches you from your current branch to the main branch |
git checkout my-new-branch | Switches you from your current branch to the my-new-branch branch |
git branch -d my-new-branch | Deletes my-new-branch from your local repo |
git merge my-new-branch | Merges changes from my-new-branch into the current branch. |
git rebase my-new-branch | Rebases changes from my-new-branch into the current branch. |
Understanding Code History
Basic Git History
Feature Branch
You decide you want to make a new login page for your app. You make a new branch called Feature-Branch and make 3 commits Z, Y, and X that collectively have code for the login page. You are now ready to integrate your branch into the main codebase.
What should happen next?
Fast-Forward
Since no one else has made any changes to the repo since you made your branch, you can simply integrate your changes using a “fast-forward”
Feature-Branch When Main is Ahead
New scenario: Since you made your branch, new code (commit D) has been incorporated into the repo that your code doesn’t have.
What should happen next?
Option 1: Merge Commit
A merge commit creates two parent pointers:
Option 2: Rebasing
Option 2: Rebasing
Rebasing involves actually making your code history look like you actually branched from D (your collaborator’s commit). In other words, you “rewrite history”. The steps:
One More Option: Squash
Conflicts
What happens if Commit D and Feature-Branch modify the same file?
Handling Conflicts
24
Trade-Offs
Merge Commits
Rebase
Class policy decision: rebasing instead of merging
Pull Requests
27