Git and GitHub
Repositories, forks, branches, commits, pull requests, and resolving merge conflicts.
- π§βπ» GitHub Workflow Guide
- π Key GitHub Workflows
- π Why Resolving Merge Conflicts Matters
- π― Practice: Merge Conflict Resolution
- Scenario 1: Simple Text Conflict in README.md
- Scenario 2: Function Logic Conflict in app.js
- Scenario 3: CSS Styling Conflict in styles.css
- Scenario 4: Multiple Conflicts in config.js
- Scenario 5: Package Dependencies Conflict
- π Real-World Practice Repository
π§βπ» GitHub Workflow Guide
GitHub is more than just a place to store code β itβs where real collaboration happens. In our class, youβll use GitHub to build your portfolio, launch projects, and collaborate on lessons. This guide walks you through the typical use cases.
π Key GitHub Workflows
Following are some use cases that we expect students will follow during their coursework.
π Reference Repository
A read-only public repository used for:
- Cloning to your local machine
- Studying code and structure
- Testing or running locally without contributing back
π‘ Example: The
pagesrepository you clone to follow the instructorβs lessons.
π€ Owner / Collaborator
You can:
- Edit files directly
- Push and merge branches
- Use GitHub Actions to publish your site or project
π‘ Example: Your Portfolio repository, created from a
student-templaterepo. You will:
- Become the Owner of your copy
- Update content to reflect your work and progress
- Use GitHub Pages to publish your portfolio website
π΄ Fork β πΏ Branch β π¬ Pull Request
- Fork: Copy the repository to your own GitHub account
- Branch: Make a new branch to isolate your changes
π§ͺ Practice: Fork and Branch Workflow
Now letβs practice the fork and branch workflow with an interactive GitHub simulator.
π Why Resolving Merge Conflicts Matters
Understanding merge conflicts is critical for effective collaboration:
- Code Integrity: Improper conflict resolution can introduce bugs, break functionality, or lose important changes
- Version Control: Understanding conflicts helps you better understand how Git tracks and merges changes across branches
- Professional Development: Merge conflict resolution is a fundamental skill for any developer working in collaborative environments
π― Practice: Merge Conflict Resolution
Ready to practice? Work through these interactive merge conflict scenarios:
π Real-World Practice Repository
Ready to practice with a real GitHub repository?
Click here to access the Merge Conflict Practice Repository β
This repository contains intentional merge conflicts for you to resolve through pull requests, just like in real-world development.
When collaborating in groups, you can either:
- All be collaborators in one shared repository, or
- Use a fork-and-pull request model where one student (the Scrum Master) owns the repository and others contribute via PRs.
π Owner / Scrum Master
- Has direct permissions to merge pull requests and manage settings
- Uses GitHub Actions to deploy the app or site to the instructor and community
βοΈ Contributors
- Fork the project repository
- Work on the
mainor feature branches
One student (Emma) is the Scrum Master and manages the main project repo. Other students create branches like noah-authentication or jessica-homepage, and open PRs to merge their features into the main branch.
π Summary Table
| Use Case | Source Repo | Your Role | Workflow Type | Contributions | Publishing |
|---|---|---|---|---|---|
| Portfolio | student |
Owner | Direct (own repo) | Direct edits | GitHub Pages |
| Lesson | pages |
Contributor | Fork β PR | Pull requests | Instructor merges |
| Project | starter_flask |
Owner | Clone β Push | Personal project | GitHub Pages/API |
| Reference Code | pages |
Reader | Clone only | No changes | Local only |
β Best Practices
- Commit messages should be meaningful:
Add login page and route handling - Never work directly on
mainunless youβre the sole owner - Use branches for features, fixes, or lessons
- Pull before you push to avoid merge conflicts
- Use issues, Kanban boards, and PRs to organize group work
- Review PRs and add feedback before merging
- Small and Feature-Specific PRs: Keep pull requests focused on a single feature or fix. This makes reviewing easier and allows for quick rollbacks if something breaks.