Step 2 of 8 in Software Engineering
Version Control & Collaboration
Git, branching, review, and working in a team. Citation needed
The whole, before the parts
Version control is the recorded history of who changed what, and why — and the single idea that carries it is that history is data you can work with. Once every change is a saved snapshot with an author and a reason, you can compare any two moments, work on two ideas in parallel, combine work from many hands, and walk backwards to find where something broke. Git is one implementation of this idea; the collaboration practices around it — small changes, honest messages, review by a colleague — are what make the history worth reading. Citation needed
For example, two people editing the same project need to preserve their starting point, explain their changes, and combine the results. A useful history also helps them investigate a defect introduced later. Citation needed
Start with saved snapshots and the places changes live, then follow separate lines of work through combining and sharing them. History inspection and review turn that record into a tool for understanding and checking the project. Citation needed
Terminology and core concepts
-
Commits: history as snapshots
A commit is a saved snapshot of the whole project plus a message and a pointer to the commit before it, so history forms a chain — and, once work splits, a graph. Citation needed
- What does a commit record of the project?
- a snapshot of all its files Citation needed
- What links one commit to history?
- a pointer to its parent commit Citation needed
- How is a commit identified in git?
- by a hash of its contents Citation needed
- Why does changing an old commit change its identity?
- the hash covers the contents Citation needed
- What does comparing two commits produce?
- a diff of what changed between them Citation needed
-
The three areas
Git separates your editable files (the working tree), the set of changes you have marked for the next commit (the staging area), and the permanent history (the repository) — staging is what lets one session become several clean commits. Citation needed
- Where do your edits live before any git command?
- the working tree Citation needed
- What does git add do?
- moves a change into the staging area Citation needed
- What does git commit take its contents from?
- the staging area, not the working tree Citation needed
- Why stage only part of your edits?
- to split one session into focused commits Citation needed
-
Branches
A branch is just a movable name pointing at a commit; creating one is free, and committing moves the name forward — which is why parallel lines of work cost nothing until they must be combined. Citation needed
- What is a branch, concretely?
- a named pointer to a commit Citation needed
- What happens to the current branch when you commit?
- it moves forward to the new commit Citation needed
- Why is creating a branch cheap?
- it writes one pointer, copies nothing Citation needed
- What does checking out a branch change?
- the working tree, to that commit's snapshot Citation needed
- What is a good scope for one branch?
- one change with one purpose Citation needed
-
Merging and conflicts
A merge creates a commit with two parents, combining two lines of work; a conflict is git admitting that both lines changed the same text and only a human knows which meaning survives. Citation needed
- How many parents does a merge commit have?
- two Citation needed
- When does a merge conflict occur?
- both branches changed the same lines Citation needed
- Can git resolve a conflict itself?
- no — it cannot judge intent Citation needed
- What must you verify after resolving a conflict?
- the combined code still builds and passes tests Citation needed
- What makes conflicts rarer?
- small branches merged often Citation needed
-
Rebase versus merge
Rebase replays your commits on top of another branch, rewriting them into new commits with a straight-line history; the trade is a cleaner story against the rule that shared history must never be rewritten. Citation needed
- What does rebase do to your commits?
- recreates them on a new base Citation needed
- What does rebase give that merge does not?
- a straight-line history Citation needed
- Why never rebase commits others already have?
- their history and yours now disagree Citation needed
- Which records what actually happened: merge or rebase?
- merge Citation needed
-
Remotes and synchronisation
Every clone is a full copy of the history; a remote is another copy you exchange commits with — fetch brings its commits to you, push sends yours to it, and nothing synchronises unless you ask. Citation needed
- What does a clone contain?
- the full history, not just the latest files Citation needed
- What does fetch do?
- downloads the remote's commits without changing your work Citation needed
- What is pull?
- fetch followed by merging into your branch Citation needed
- Why can a push be rejected?
- the remote has commits you lack Citation needed
-
History as a tool
A commit message states why a change was made, because the diff already shows what; good messages turn history into the system's best documentation and let you search it like evidence. Citation needed
- What should a commit message explain?
- why the change was made Citation needed
- What does git blame tell you about a line?
- the commit and author that last touched it Citation needed
- What does git bisect find?
- the first commit where a behaviour broke Citation needed
- What makes bisect fast over n commits?
- binary search — about log n checks Citation needed
- What does version control answer in an incident?
- what changed just before this broke Citation needed
-
Code review
Review is a second reader checking a change before it joins the shared history; its yield is highest on small changes, and its real products are shared knowledge and a readable standard, not just caught bugs. Citation needed
- Why do small changes get better reviews?
- the reviewer can actually hold them in mind Citation needed
- What should a reviewer comment on besides bugs?
- clarity for the next reader Citation needed
- Who learns from a review?
- both author and reviewer Citation needed
- What does review spread through a team?
- knowledge of code no one person owns Citation needed
- What tone keeps review useful?
- comments about the code, never the author Citation needed
Sources
- Scott Chacon and Ben Straub, Pro Git — the standard reference, strongest on what git actually stores.
- Titus Winters, Tom Manshreck, and Hyrum Wright, Software Engineering at Google — code review and collaboration as engineering practice at scale.
- David Thomas and Andrew Hunt, The Pragmatic Programmer — version control as a daily discipline, not an emergency tool.
Learning path
Continue through Software Engineering in order, using the concepts above to connect this topic to the next.