Code Review in Git / GitHub / Azure DevOps
1. What is Code Review?
Code review is the process of examining another developer’s code changes before those changes are merged into the main branch.
The reviewer checks whether the code is:
- Correct and meets the requirement
- Easy to understand and maintain
- Following coding standards
- Free from obvious bugs
- Secure and performant
- Properly tested
- Not introducing unnecessary or breaking changes
In team development, code review usually happens through a Pull Request (PR).
Git itself does not provide a full code-review workflow. Platforms such as GitHub and Azure DevOps provide Pull Requests and code-review features.
2. Simple Sample
Suppose a developer is implementing a login feature.
git switch -c feature/login
# Make changes
git add .
git commit -m "Add login validation"
git push -u origin feature/login
The developer then creates a Pull Request:
feature/login
|
| Pull Request
v
main
A team member reviews the changed files before approving the PR.
3. Detailed Explanation
Typical Code Review Flow
Step 1: Developer creates a feature branch
git switch -c feature/login
Branch structure:
main
|
A---B
\
C---D feature/login
C and D contain the login-related changes.
Step 2: Developer pushes the branch
git push -u origin feature/login
Now the branch is available in GitHub or Azure DevOps.
Step 3: Developer creates a Pull Request
For example:
Source branch : feature/login
Target branch : main
The PR essentially says:
"I want to merge the changes from
feature/loginintomain. Please review them first."
Step 4: Reviewer examines the changes
The reviewer can inspect the diff showing what was added, modified, or removed.
For example:
- if (user != null)
+ if (user != null && user.IsActive)
The reviewer may identify an issue and leave a comment such as:
Should we also check whether the account is locked?
Step 5: Developer fixes the issue
The developer modifies the code and pushes another commit:
git add .
git commit -m "Handle locked user accounts"
git push
The Pull Request is automatically updated with the new commit.
Step 6: Automated checks may run
The PR may also trigger a CI pipeline:
Pull Request
|
+----> Build
|
+----> Unit Tests
|
+----> Code Analysis
|
+----> Security Checks
These automated checks support code review but do not completely replace human review.
Step 7: Reviewer approves the PR
Once the reviewer is satisfied:
Developer
|
v
Feature Branch
|
v
Pull Request
|
v
Code Review
|
+--> Comments / Changes Requested
| |
| v
| Developer Fixes
| |
| +------> Review Again
|
v
Approval
|
v
Merge
|
v
main
The feature can then be merged into main.
4. Why is Code Review Important?
1. Finds bugs early
Another developer may notice problems the original developer missed.
For example:
if (user != null)
{
Login(user);
}
A reviewer might notice that the code doesn't check whether the user is active or locked.
2. Improves code quality
Reviewers can suggest cleaner or more maintainable implementations.
For example, they may identify:
- Duplicate code
- Poor naming
- Unnecessary complexity
- Incorrect exception handling
- Missing validation
3. Improves security
Code review can catch security problems such as:
var password = "Admin@123";
or accidentally committed secrets:
{
"ConnectionString": "Server=...;Password=ActualPassword"
}
These should not normally be committed to source control.
4. Maintains coding standards
A team may have conventions for:
- Naming
- Project structure
- Error handling
- Logging
- Dependency injection
- Async programming
- Unit testing
Code review helps ensure developers follow those standards consistently.
5. Shares knowledge
If only one developer understands a feature, that creates a knowledge dependency.
With code review:
Developer A writes code
|
v
Developer B reviews it
|
v
Both understand the implementation
This improves team knowledge sharing.
6. Protects important branches
Teams commonly prevent developers from directly pushing to main.
Instead:
Developer
↓
Feature Branch
↓
Pull Request
↓
Code Review
↓
Approval
↓
Merge into main
GitHub branch protection rules or Azure DevOps branch policies can enforce requirements such as reviewers and successful build checks.
5. Code Review vs Pull Request
| Code Review | Pull Request |
|---|---|
| Process of examining code | Mechanism used to propose changes |
| Focuses on code quality and correctness | Focuses on merging one branch into another |
| Reviewer provides comments/feedback | PR provides the interface for review |
| Can theoretically happen without a PR | Commonly used to facilitate code review |
So:
Pull Request = mechanism/workflow
Code Review = activity performed within that workflow
6. Key Points
- Code review means examining code changes before merging them.
- It is commonly performed through a Pull Request.
- GitHub and Azure DevOps provide code-review functionality; Git itself is primarily the version-control system.
- Reviewers check correctness, maintainability, security, tests, and coding standards.
- Reviewers can comment, request changes, or approve.
- Developers can push additional commits to address review comments.
- CI pipelines can automatically build and test PR changes.
- Code review helps catch defects before they reach
mainor production. - It also improves knowledge sharing across the team.
- GitHub branch protection and Azure DevOps branch policies can require reviews before merging.
7. Interview Answer
Code review is the process of reviewing another developer's code changes before they are merged into the main branch. It is commonly performed through a Pull Request in GitHub or Azure DevOps. The reviewer checks the code for correctness, bugs, security issues, coding standards, maintainability, and proper testing. If issues are found, the reviewer requests changes; after the developer fixes them and the required checks pass, the PR can be approved and merged. Code review is important because it improves code quality, catches defects early, enforces team standards, and promotes knowledge sharing.