Skip to content
Computer Science · 11th Grade · Object-Oriented Programming · Weeks 19-27

Version Control with Git

Using Git to manage code changes, collaborate with others, and track project history.

Common Core State StandardsCSTA: 3B-AP-18

About This Topic

Version control is one of the most practical professional skills students can acquire in their CS education, and Git is the industry-standard tool for it. Every major software company uses Git, and platforms like GitHub are central to open-source collaboration. CSTA standard 3B-AP-18 expects students to document and communicate the design and development of computational artifacts using version control as part of that process.

At its core, Git tracks changes to files over time, allowing developers to see who changed what and when, revert to earlier versions, and work on separate features simultaneously through branching. Students often grasp the basic add-commit-push cycle quickly but struggle with the mental model behind branching and merging, concepts that take practice to internalize.

Active learning is highly effective here because Git is genuinely learned by doing. Reading about merge conflicts is far less instructive than intentionally creating one and resolving it. Collaborative coding exercises where students work on the same repository simultaneously give them authentic experience with the real challenges version control solves.

Key Questions

  1. Explain the importance of version control systems like Git in collaborative development.
  2. Differentiate between common Git commands (commit, push, pull, branch, merge).
  3. Analyze how Git helps manage conflicts and maintain code integrity in a team environment.

Learning Objectives

  • Demonstrate the use of Git commands (init, add, commit, push, pull, branch, merge) to manage code versions in a personal project.
  • Analyze a Git log to identify the sequence and authorship of changes within a collaborative repository.
  • Compare and contrast the outcomes of merging branches with and without conflicts.
  • Create a new branch in a Git repository, make changes, and merge it back into the main branch.
  • Explain the purpose of a .gitignore file in excluding specific files from version control.

Before You Start

Basic File Management

Why: Students need to understand how to create, save, and organize files to track changes effectively.

Introduction to Programming Concepts

Why: Students should have a foundational understanding of writing and modifying code before learning to manage its versions.

Key Vocabulary

Repository (Repo)A storage location for all the files and version history of a project managed by Git.
CommitA snapshot of the project's files at a specific point in time, saved to the repository's history.
BranchAn independent line of development within a repository, allowing work on new features without affecting the main codebase.
MergeThe process of combining changes from one branch into another, integrating different lines of development.
Remote RepositoryA version of the project's repository hosted on a server, such as GitHub or GitLab, used for collaboration and backup.
ConflictA situation that occurs when Git cannot automatically combine changes from different branches, requiring manual resolution.

Watch Out for These Misconceptions

Common MisconceptionGit automatically saves your work like an autosave feature.

What to Teach Instead

Git only records a version when you explicitly commit. If you make changes without committing, Git doesn't know about them yet. Students often lose work by assuming their changes are safely tracked when they've only edited files without staging and committing. Getting into a regular commit habit is a skill that takes practice.

Common MisconceptionBranching is only for large teams working on big projects.

What to Teach Instead

Branching is useful even for a single developer working alone. Creating a branch for each new feature or bug fix means your main branch stays stable and working, and you can experiment without risk. Even student solo projects benefit from this discipline. The habit pays dividends when students join team environments.

Common MisconceptionA merge conflict means something went seriously wrong.

What to Teach Instead

Merge conflicts are a normal, expected part of collaborative development, they happen whenever two people edit the same part of the code at the same time. Resolving them is a standard skill, not an emergency. The discomfort students feel their first time is normal and temporary; with practice, conflict resolution becomes routine.

Active Learning Ideas

See all activities

Real-World Connections

  • Software engineers at Google use Git daily to manage the vast codebase for products like Chrome and Android, coordinating changes across thousands of developers worldwide.
  • Open-source projects, such as the Linux kernel or the Python programming language, rely on Git and platforms like GitHub for global collaboration, allowing anyone to contribute code and track its history.
  • Game development studios, like Blizzard Entertainment, utilize Git to manage game assets and code, enabling teams to work on different game features simultaneously and merge them into the main game build.

Assessment Ideas

Quick Check

Present students with a scenario: 'You are working on a new feature, and your teammate has made changes to the same file. What Git command should you use first to get their latest changes?' Ask students to write their answer and a one-sentence explanation of why.

Exit Ticket

On a slip of paper, have students list three essential Git commands and briefly describe the purpose of each. For example: 'commit - saves changes', 'push - sends local commits to remote', 'pull - gets remote changes'.

Peer Assessment

In pairs, students create a simple branching and merging exercise. One student creates a branch, makes a change, and commits. The other student pulls, makes a conflicting change, and commits. They then swap roles to resolve the conflict. Students provide feedback on their partner's ability to explain the steps and resolve the conflict.

Frequently Asked Questions

What is version control and why do developers use it?
Version control is a system that records changes to files over time so you can see what changed, when, and who changed it, and revert to any earlier state if needed. Developers use it because software projects involve many files changing over months or years, often with multiple people working simultaneously. Without version control, coordinating those changes and recovering from mistakes would be extremely difficult.
What is the difference between git commit, push, and pull?
A commit saves a snapshot of your changes to your local repository with a message describing what changed. A push sends those local commits to a remote repository (like GitHub) where others can see them. A pull fetches and integrates changes from the remote into your local copy. Commit is local; push and pull move changes between local and remote. Understanding this distinction is essential for collaborative workflows.
How does active learning help students actually learn Git?
Git is a tool that only makes sense through hands-on use. Reading about merge conflicts is far less instructive than creating one intentionally and working through it with a partner. Collaborative labs, paired coding exercises, and simulations that mirror real-world scenarios build the mental model that makes Git commands feel logical rather than arbitrary. Discussion afterward, what went wrong, what helped, cements the learning.
What is a branch in Git and when should you use one?
A branch is an independent line of development that diverges from the main codebase. You use one when you want to work on a new feature or fix without risking the stability of the main branch. Once your work is complete and tested, you merge it back. Branches let multiple features be developed simultaneously and make it easy to abandon a bad idea without affecting working code.