If you've ever worked on a document with multiple people, you know the chaos: "Final_v2_ACTUAL_FINAL.docx". Now imagine that with hundreds of files and dozens of developers. That's what Git solves.
What is Git and why it matters
Git is a version control system that remembers every change ever made to code, who made it, and why. Everyone works on their own copy of the codebase, and Git tracks how all those copies fit together.
The business case: When something breaks, Git tells you exactly what changed and who changed it. New developers can see the entire project history. Mistakes can be rolled back to any previous version.
Commits, branches, and merges
Commits: Save points in your code
A commitWhat is commit?A permanent snapshot of your staged changes saved in Git's history, identified by a unique hash and accompanied by a message describing what changed. captures the exact state of your code at a moment, with a message explaining what changed, like "Fix login button on mobile" or "Add password reset feature". Good commit messages tell the story of what happened to the codebase.
Branches: Parallel versions of code
Branches let developers work on different features without interfering with each other. The main branch (often called main) is the "source of truth", the official version that customers use. To add a feature, developers create a new branch, work on it in isolation, then merge it back when it's ready.
Example: Your team is building a new checkout flow. One developer works on the payment form, another on the confirmation screen, a third fixes a cart bug. Each creates their own branch, works independently, and merges when everything works.
Merges: Combining branches
When a feature is ready, the developer merges their branch back into main. Git combines the changes automatically, most of the time. When two developers changed the same line, that's a "merge conflictWhat is merge conflict?A situation where Git can't automatically combine changes from two branches because both modified the same lines, requiring you to manually choose which version to keep.," and someone must manually decide which version to keep.
Pull requests: Code review before it goes live
A pull requestWhat is pull request?A proposal to merge code changes into a shared branch, where teammates review the diff before it's accepted. (PR) is a proposal: "I've made changes on my branch. Please review them before we merge to main."
The PR process:
- Developer finishes their feature on a branch
- They open a pull request describing what changed and why
- Other developers review, leave comments, approve or request changes
- Once approved, the branch is merged into main
Code reviews: Catching issues early
Code reviews aren't about catching mistakes. They're about sharing knowledge, catching bugs before customers do, ensuring maintainability, and keeping coding standards consistent.
The key questions: "Would I understand this code six months from now?" "Does this solve the problem in the simplest way?" "Are there edge cases we haven't considered?"
Common Git workflows
GitFlow: Structured and predictable
Two permanent branches: main (production-ready) and develop (integration). Feature branches split off develop, and when a release is ready, develop merges into main. Best for teams with scheduled releases.
Trunk-based developmentWhat is trunk-based development?A workflow where all developers commit frequently to a single shared branch, relying on feature flags to hide incomplete work.: Fast and continuous
Everyone commits directly to main or merges via very short-lived feature branches (hours, not weeks). Best for teams doing continuous deployment multiple times per day.
| Workflow | Branch structure | Release frequency | Best for |
|---|---|---|---|
| GitFlow | main + develop + feature branches | Scheduled (weekly/monthly) | Teams with formal release cycles |
| Trunk-based | Mostly main only | Continuous (multiple times daily) | Teams doing continuous deployment |
Quick reference: Git terminology
| Term | What it means | Business analogy |
|---|---|---|
| Commit | A snapshot of code changes | Saving a document version |
| Branch | A parallel version of the code | Working on a copy of a document |
| Merge | Combining branches | Merging two document versions |
| Pull request | Request to merge code | Asking for approval before publishing |
| Repository (repo) | The project's folder with all its history | A filing cabinet with every version of every document |
| Clone | Downloading a copy of the repository | Making a photocopy of the filing cabinet |