Version Control and Collaboration (Git)
Understand Git-based collaboration workflows that help backend teams ship code safely and efficiently.
Why Version Control Exists
When multiple developers work on the same codebase, changes must be tracked, coordinated, and preserved to prevent conflicts and lost work.
- Version control systems maintain a history of code changes over time.
- They record who made changes and when they occurred.
- They prevent developers from overwriting each other’s work.
Details
When only one person is working on a project, saving files locally is usually enough. But as soon as multiple developers start modifying the same codebase, problems appear quickly—changes can conflict, overwrite each other, or introduce bugs that are hard to trace.
Version control systems solve this by turning every code change into a tracked event. Instead of unmanaged edits, each change is recorded and added to a structured timeline of the project.
This timeline includes important metadata such as who made the change, when it happened, and why it was made. That context is critical for debugging, collaboration, and maintaining code quality over time.
Conceptually, version control sits between raw code changes and long-term project history. It transforms scattered edits into an organized system that allows teams to work together without breaking each other’s progress.
Commits
A commit is a snapshot of the codebase at a specific moment, capturing what changed along with important context about that change.
- Each commit records the exact code changes made.
- It includes metadata such as author, timestamp, and a commit message.
- Commits form a chronological history of the project.
Details
A commit represents a point-in-time snapshot of your entire codebase. Instead of saving individual files manually, version control systems package all changes into a single unit called a commit.
Each commit contains not just the code differences, but also metadata: who made the change, when it was made, and a message describing the purpose of the change. This message is critical—it explains why the change exists, not just what changed.
As commits accumulate, they form a timeline of the project: Commit 1 → Commit 2 → Commit 3. This history allows developers to trace bugs, understand how features evolved, and revert the system to a previous state if needed.
Without commits, there would be no reliable way to understand or manage the evolution of a codebase.
Branches
Branches allow developers to work on changes independently without affecting the stability of the main codebase.
- Branches isolate new features or fixes so development does not interfere with the stable main branch.
- They prevent incomplete or experimental code from breaking production-ready systems.
- They enable multiple developers to work on different tasks simultaneously without conflicts.
Details
A branch is essentially a separate line of development within the same project. Instead of making changes directly to the main branch (often called main or master), developers create a new branch to work on a specific feature or fix.
This means you can modify files, add features, or experiment freely without impacting the stable version of the code. The main branch remains clean and production-ready while work continues elsewhere.
Conceptually, branching creates a structure like:
Main
│
└ Feature Branch
Each branch evolves independently with its own commits. Once the work is complete and tested, it can be safely integrated back into the main branch.
Without branches, teams would constantly interfere with each other’s work, making collaboration slow, risky, and error-prone.
Feature Branch Workflow
The feature branch workflow allows developers to safely build and integrate new features without disrupting the main production code.
- Developers create a separate branch to work on a specific feature or task.
- All development and commits happen in that branch without affecting the main branch.
- Once complete, changes are merged back into the main branch in a controlled way.
Details
The feature branch workflow is one of the most widely used development patterns in modern software teams. Instead of working directly on the main branch, developers create a new branch for each feature, bug fix, or improvement.
The process follows a clear sequence:
Main branch
│
Feature branch
│
Work on feature
│
Merge back to main
First, a branch is created from the main branch. Then, all development happens within that branch, with commits capturing progress along the way. This keeps the main branch stable and production-ready at all times.
Once the feature is complete and tested, the branch is merged back into the main branch. This ensures that only reviewed and finalized changes become part of the core codebase.
This workflow reduces risk, improves collaboration, and makes it easier to manage complex development across multiple contributors.
Merging
Merging integrates changes from one branch into another, making completed work part of the main codebase.
- Merging combines the commits from a feature branch into the main branch.
- It allows completed and tested work to become part of the core codebase.
- It preserves the history of changes while integrating different lines of development.
Details
Merging is the process of taking changes from one branch—typically a feature branch—and integrating them into another branch, usually the main branch.
Conceptually, it looks like:
Feature Branch
│
Merge
↓
Main Branch
When a merge happens, all commits from the feature branch are applied to the target branch. This makes the new feature or fix part of the main codebase.
Merging is a critical step in collaborative development because it brings together work done in isolation. It ensures that independent changes from different developers are unified into a single, consistent project.
However, merging is not always automatic—if multiple branches modify the same parts of the code, conflicts may occur and must be resolved manually before the merge can complete.
Pull Requests
Pull requests provide a structured way to propose, review, and approve changes before they are merged into the main codebase.
- Pull requests allow developers to propose changes from a feature branch before merging.
- They enable code review, discussion, and feedback from other developers.
- They improve code quality by catching issues before integration into the main branch.
Details
A pull request (PR) is a collaboration mechanism used to review and approve changes before they are merged into the main branch.
The typical flow looks like:
Feature Branch
↓
Pull Request
↓
Code Review
↓
Merge
After completing work on a feature branch, a developer opens a pull request on a platform like GitHub or GitLab. This signals that the changes are ready for review.
Other developers can then examine the code, leave comments, suggest improvements, and discuss implementation details. This review process helps catch bugs, enforce coding standards, and ensure the changes align with the overall system design.
Only after the pull request is approved are the changes merged into the main branch. This creates a controlled and collaborative integration process rather than blindly merging code.
In practice, pull requests are one of the most important tools for maintaining code quality in team environments.
Rebasing
Rebasing rewrites a branch so it starts from a newer base commit, creating a cleaner and more linear project history.
- Rebasing moves a feature branch to start from the latest commit of the main branch.
- It rewrites commit history to appear as if the work was built on top of the newest changes.
- It results in a cleaner, more linear project history compared to merging.
Details
Rebasing is an alternative to merging that changes the base of a branch. Instead of combining histories, it replays commits from a feature branch onto a newer commit from the main branch.
Conceptually:
Main: A → B → C
Feature: A → D → E
After rebasing the feature branch onto C:
Main: A → B → C
Feature: C → D → E
This means the feature branch now appears as if it was created from the latest state of the main branch, even if it originally started earlier.
The main advantage is a cleaner, linear commit history without extra merge commits. This makes the project timeline easier to read and reason about.
However, rebasing rewrites commit history. This can cause problems if the branch is already shared with others, since it changes commit identifiers. For that reason, rebasing is typically used on local or private branches before merging.
Merge Conflicts
Merge conflicts occur when multiple branches modify the same part of the code, requiring manual resolution before merging can complete.
- Conflicts happen when two branches change the same lines or overlapping parts of a file.
- Git cannot automatically decide which change is correct, so it pauses the merge.
- Developers must manually choose or combine the changes before completing the merge.
Details
Merge conflicts are a natural part of collaborative development. They occur when two branches modify the same section of code in different ways.
Conceptually:
Branch A changes a line
Branch B changes the same line
↓
Conflict detected
Since version control systems cannot determine which change is correct, the merge process is stopped and the conflict must be resolved manually.
The resolution process looks like:
Conflict
↓
Manual resolution
↓
Merged result
Developers review both versions of the conflicting code and decide which one to keep, or they may combine parts of both changes into a new final version.
While conflicts may seem like errors, they are actually safeguards. They prevent unintended overwrites and force developers to make explicit decisions about how code should evolve.
Git Platforms for Collaboration
Git manages version control locally, while platforms like GitHub and GitLab add collaboration, automation, and project management capabilities.
- GitHub and GitLab host repositories for shared team access.
- They provide features like pull requests and issue tracking for collaboration.
- They support CI/CD pipelines for automated testing and deployment.
Details
Git is responsible for tracking code changes and maintaining history, but it does not provide built-in tools for team collaboration.
Platforms like GitHub and GitLab extend Git by hosting repositories and providing interfaces for teams to work together efficiently.
Conceptually, developers push their code to a shared repository, and the platform sits on top to manage collaboration, reviews, and workflows.
These platforms make it possible to coordinate large teams, enforce development processes, and automate parts of the software lifecycle such as testing and deployment.
Question Section
1 / 5
This track is locked
Buy this track once to unlock all of its lessons.