Version Control with Git
Using industry-standard tools to track changes and collaborate on shared codebases.
Need a lesson plan for Computer Science?
Key Questions
- How does version control facilitate collaboration among hundreds of developers on one project?
- What are the consequences of a poorly managed merge conflict?
- How can we use branching to experiment with new features without breaking the main product?
Ontario Curriculum Expectations
About This Topic
Version control with Git enables developers to track code changes, collaborate on shared projects, and recover from errors efficiently. Grade 12 students master core commands such as init, add, commit, push, pull, branch, and merge. They explore how Git repositories store history as a series of snapshots, allowing multiple contributors to work simultaneously without conflicts. This topic addresses key questions about scaling collaboration to hundreds of developers, resolving merge conflicts, and using branches for safe experimentation.
In the Ontario Computer Science curriculum, Git aligns with software engineering principles (CS.SE.11) and project management (CS.PM.5). Students apply these tools to simulate professional workflows, fostering skills in debugging, teamwork, and iterative development. Understanding Git's distributed nature helps them appreciate how open-source projects like Linux succeed through coordinated contributions.
Active learning shines here because students experience real merge conflicts and branching outcomes firsthand. Pair programming on shared repos or group simulations of pull requests turns abstract commands into tangible team dynamics, building confidence and retention through trial and error in a safe environment.
Learning Objectives
- Demonstrate the use of Git commands (init, add, commit, push, pull, branch, merge) to manage a code repository.
- Analyze the history of a Git repository to identify changes made by collaborators.
- Compare and contrast the outcomes of different branching strategies for feature development.
- Critique a pull request, providing specific feedback on code changes and adherence to project standards.
- Create a new branch, implement a small feature, and merge it back into the main branch.
Before You Start
Why: Students need to be comfortable navigating directories and executing commands to use Git effectively.
Why: Understanding how files and folders are structured is essential for managing code within a repository.
Key Vocabulary
| Repository (Repo) | A project's storage location for all its files and version history, managed by Git. |
| Commit | A snapshot of the repository at a specific point in time, along with a message describing the changes made. |
| Branch | An independent line of development within a repository, allowing for parallel work without affecting the main codebase. |
| Merge Conflict | A situation that occurs when Git cannot automatically combine changes from different branches, requiring manual resolution. |
| Pull Request (PR) | A formal request to merge changes from one branch into another, typically used for code review and discussion before merging. |
Active Learning Ideas
See all activitiesPairs: Branching New Features
Students clone a shared class repository, create a feature branch, add and commit a simple function, then push it. Partners review via pull request, merge to main, and discuss changes. End with a class share-out on branch benefits.
Small Groups: Merge Conflict Resolution
Groups edit the same file on separate branches, intentionally create conflicts by changing overlapping lines, then resolve using git merge and editor tools. Record steps in a shared doc. Debrief on prevention strategies.
Whole Class: Collaborative Code Base
Class contributes to one repo: assign roles like feature dev, reviewer, integrator. Use issues for tasks, pull requests for changes. Monitor progress live via projector, vote on merges.
Individual: Personal Repo History
Students initialize a repo, make 10 commits with messages, create branches, and explore git log and reflog. Revert a 'bad' commit. Reflect on history tracking value in a journal.
Real-World Connections
Software developers at Google use Git to manage the codebase for projects like Android, coordinating contributions from thousands of engineers worldwide.
Game development studios like Ubisoft employ Git for version control of game assets and code, enabling large teams to collaborate on complex projects like Assassin's Creed.
Open-source projects, such as the Linux kernel, rely heavily on Git and pull requests to manage contributions from a global community of volunteer developers.
Watch Out for These Misconceptions
Common MisconceptionGit branches create full copies of the entire codebase.
What to Teach Instead
Branches are lightweight pointers to commits, saving space and enabling fast switches. Hands-on branching activities let students time branch creation versus copying files, revealing efficiency. Group merges reinforce that branches share history until divergence.
Common MisconceptionMerge conflicts only happen with poor coding.
What to Teach Instead
Conflicts arise from simultaneous edits to the same lines, regardless of code quality. Simulating conflicts in pairs helps students practice resolution tools like git mergetool. Discussions clarify that communication prevents most issues.
Common MisconceptionGit is only for large teams, not solo developers.
What to Teach Instead
Solo devs use Git for backups, experimentation, and history. Individual repo setups show students how to revert mistakes safely. This builds habits before team projects.
Assessment Ideas
Present students with a scenario: 'You just finished writing a new function. What Git command do you use to stage it, and what command do you use to save it permanently?' Review responses to gauge understanding of basic add and commit actions.
Pose the question: 'Imagine two developers modify the same line of code on different branches. What is this called, and what are two strategies to resolve it?' Facilitate a class discussion on merge conflicts and their resolution methods.
Students create a simple feature branch, make a commit, and then initiate a pull request (simulated or actual). Their partner reviews the pull request, checking for a clear commit message and a logical change, then provides one specific suggestion for improvement.
Suggested Methodologies
Ready to teach this topic?
Generate a complete, classroom-ready active learning mission in seconds.
Generate a Custom MissionFrequently Asked Questions
How does Git facilitate collaboration on large projects?
What are the consequences of poorly managed merge conflicts?
How can active learning help students master Git?
What are essential Git commands for beginners?
More in Software Engineering Principles
Introduction to Software Engineering
Students will learn about the software development lifecycle and the importance of systematic approaches to building software.
2 methodologies
Requirements Engineering
Understanding how to gather, analyze, and document user and system requirements for a software project.
2 methodologies
Agile Methodologies
Comparing traditional linear development models with modern iterative approaches.
2 methodologies
Waterfall and Hybrid Models
Exploring the traditional Waterfall model and hybrid approaches, identifying their strengths and weaknesses.
2 methodologies
Software Design Principles
Learning about design patterns, modularity, cohesion, and coupling for creating maintainable and scalable code.
2 methodologies