Git
How to integrate your work
Without Git
How do I share my changes?
How do we combine changes to the same file?
How do I undo something?
Who changed this, and why?
- Before git: email zips, shared drives, manual merging
- "final_final_v3_ACTUALLY_FINAL.zip"
Core Concepts
Commit - a saved snapshot of changes
Branch - a separate timeline of changes
Merge - combining two branches
- main is the primary branch — the source of truth
Commit
Bundle and save related changes
Commit
Stage your changes first
git add style.css index.html
- Working directory: files you've changed but not yet committed
- Staging area: files you've marked to include in the next commit
- git add lets you choose which changes to bundle together
- You might change 5 files but only want to commit 2 of them
Commit
Then commit with a message
git commit -m "update header styles"
- Message is for your team and future you
- Logical unit — not "saved work" but "fixed login bug"
Branch
A separate timeline of changes
Branch
git branch feature/new-header
git checkout feature/new-header
# make changes to your files
git add index.html
git commit -m "try a new header"
git checkout main
Changes stay on feature/new-header
- checkout -b: create and switch in one step
- main is untouched while you work on the branch
- Naming: feature/, fix/, chore/ prefixes
Merge
Bring work back together
Merge
git checkout main
git merge feature/new-header
git log
- Merge INTO main (switch to it first)
Merge Conflicts
When two branches change the same line
Merge Conflicts
<<<<<<< HEAD
background: blue;
=======
background: red;
>>>>>>> feature/new-header
- Git marks both versions in the file and stops the merge
- HEAD = your current branch, below the === is the incoming branch
- Pick one, delete the markers, then save
Merge Conflicts
Resolve and complete the merge
# edit the file to resolve the conflict
git add style.css
git commit -m "merge feature/new-header"
- After resolving, stage the file and commit as normal
- Most editors (VS Code) have a UI to accept current/incoming/both
Remote
A shared copy of the repo everyone syncs to
- Everything so far is local
- Remote is hosted on GitHub — the team's source of truth
Remote
Clone the repo
git clone https://github.com/codersforcauses/software-engineering-practices-demo-2026-winter
- Downloads the full repo history once
- Sets up "origin" pointing back to GitHub automatically
Remote
Push your branch to the remote
git checkout -b your-name/update-my-file
git add changed-file
git commit -m "update my file"
git push origin your-name/update-my-file
- push sends your branch up to GitHub
- Branch is now visible to the whole team
Remote
Pull Request
- PR = request to merge your branch into main
- Teammates review, comment, request changes
- Nothing merges without review
- GitHub → "Compare & pull request" after pushing
Your turn
Clone the repo
Create a branch with your name
Modify an existing file
Stage and commit the change
Push and open a pull request
- Common issues: not being inside the repo folder, auth on first push
- GitHub will prompt to authenticate via browser