Version Control and Collaborative Workflows
Fall 2024
1
Reminder of what we did Last Week
Today’s Agenda
3
Today’s Agenda
4
Discussion of Chapter 16: Quick Recap
Today’s Agenda
6
Collaborative git workflows
When you start collaborating with other people, the workflow gets more complex. A few other concepts to introduce here:
7
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:
8
Main
Branch Commands Using git
9
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.
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 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?
Trade-Offs
Merge Commits
Rebase
Class policy decision: rebasing instead of merging
Pull Requests
22
Handling Conflicts
23
Authentication: What is a public/private key pair?
24
Public/private keys on Servers
25