Version control with git – commits, branches, merges and a shared remote
Computer ScienceCareers in ComputingAges 17–18
How do you mainly use this simulation?
Use it with your class: students open it from a link or a QR code, with no account needed.
Edit a shared file, commit your changes and watch the commit graph grow. Create a feature branch, switch between branches and merge them: a fast-forward, a merge commit, or a conflict that you resolve yourself, with the conflict markers exactly as git writes them. On the team screen a teammate pushes to the shared remote, so your push is rejected until you pull, merge and push again.
Lesson: Software development careers: version control with git and team workflows
What it shows
Software teams keep every version of their code with a version control system, and git is the most widely used. A commit is a snapshot of the files with a message and a link to its parent; a branch is a movable name for a commit. Merging joins two lines of work: if only one side moved, git simply moves the branch forward (a fast-forward); otherwise it makes a merge commit, or stops with a conflict when both sides changed the same or neighbouring lines. Teams share a remote repository and push, fetch and pull through it.
How to use
Choose a Line and a New text to edit club.txt, then press git commit. Press git branch feature and git switch feature, commit on the branch, switch back and try git merge feature. After a conflict, press Keep HEAD's version or Keep feature's version, then git commit. On Team and remote, press Teammate: commit and push, then try git push, git fetch and git pull.
Parameters you can change
- Screen Branches and merges, Team and remote
- Starting repository Two commits on main, main and feature both changed line 2
Questions to explore
- Why does git merge sometimes only move the branch forward and sometimes make a new commit with two parents?
- Which changes on two branches end in a conflict, and how do the conflict markers show both versions?
- Why was your push rejected after your teammate pushed, and what does git pull do to fix it?