Module 3 — GitHub Pull Requests¶
Lesson 30: Pull Request Management — Merge Conflicts, Updating Branches and Keeping PRs Healthy¶
Practical Lesson¶
Level: Intermediate–Advanced
Estimated time: 3–4 hours
Lesson Introduction¶
In Lesson 28, you learned how to create, configure, and manage Pull Requests.
In Lesson 29, you practised advanced Pull Request reviews, including inline comments, review decisions, suggested changes, and resolving conversations.
Now we'll address another important part of professional GitHub collaboration: keeping Pull Requests synchronized with their target branches and resolving merge conflicts.
Imagine you're working on your restaurant POS application.
You create a feature branch:
While you're implementing the feature, another developer merges changes into main.
Your feature branch is now behind main.
What happens if both developers modify the same part of a file?
You may encounter a merge conflict.
Merge conflicts are a normal part of collaborative development. They don't necessarily indicate that something is wrong with your code. They simply mean Git needs your help to determine how different changes should be combined.
In this lesson, you'll learn how to understand, reproduce, prevent, and resolve these situations while maintaining healthy Pull Requests.
1. Learning Objectives¶
By the end of this lesson, you should be able to:
- Explain what merge conflicts are and why they happen.
- Understand branch divergence and fast-forward versus non-fast-forward updates.
- Identify common types of merge conflicts.
- Understand how Git compares changes from different branches.
- Detect merge conflicts locally and through GitHub.
- Update feature branches using Git merge.
- Update feature branches using Git rebase.
- Resolve conflicts manually using Git.
- Resolve conflicts using the VS Code Merge Editor.
- Abort an unsuccessful merge or rebase safely.
- Understand how new commits affect Pull Request reviews and approvals.
- Recognize outdated and stale Pull Requests.
- Keep Pull Requests focused, reviewable, and maintainable.
- Collaborate with another developer to resolve conflicting changes.
- Publish your Lesson 30 documentation using your established GitHub workflow.
2. Understanding Merge Conflicts¶
2.1 What Is a Merge Conflict?¶
A merge conflict occurs when Git cannot automatically combine changes from different branches.
Consider the following situation.
Your main branch contains:
You create a feature branch and change it to:
Meanwhile, another developer changes the same line in main:
Git now has two different modifications to the same line.
Which value should it use?
Git cannot reliably determine the correct business requirement.
You must resolve the conflict.
2.2 Visualizing Branch Divergence¶
Imagine the following history:
Both branches started from commit B.
However:
- Developer A committed
Don the feature branch. - Developer B committed
Con main.
The branches have diverged.
When you attempt to integrate main into the feature branch, Git needs to combine the two histories.
If the changes are compatible, Git may complete the merge automatically.
If the changes conflict, Git pauses and requests manual resolution.
2.3 Common Causes of Merge Conflicts¶
| Situation | Explanation |
|---|---|
| Same-line modifications | Two developers modify the same lines differently. |
| Delete versus modify | One branch deletes a file while another modifies it. |
| Rename conflicts | Branches rename or move files incompatibly. |
| Add/add conflicts | Both branches create a file at the same path with different content. |
| Overlapping structural changes | Different modifications cannot be combined safely. |
Important: Modifying the same file does not automatically produce a merge conflict.
For example:
Developer A changes line 10.
Developer B changes line 100.
Git can often combine these changes automatically.
The important distinction is whether the changes overlap in a way Git cannot reconcile.
2.4 Three Important Concepts¶
| Concept | Meaning |
|---|---|
| Branch divergence | Two branches have different commits after their common ancestor. |
| Merge conflict | Git cannot automatically combine particular changes. |
| Conflict resolution | A developer determines the correct final content. |
Branch divergence does not necessarily mean a conflict exists.
You can have divergent branches that merge successfully without any manual intervention.
3. Understanding Fast-Forward, Non-Fast-Forward, Merge and Rebase¶
Before resolving conflicts, understand how Git integrates branches.
3.1 Fast-Forward Merge¶
A fast-forward merge happens when the current branch has no additional commits that prevent Git from simply moving its branch pointer forward.
Example:
If main is still at B, it can advance to D.
After:
No merge commit is required.
Command:
3.2 Non-Fast-Forward Merge¶
A non-fast-forward merge happens when both branches have independent commits.
Example:
Git needs to combine both histories.
A merge commit may be created:
The merge commit M records the integration of the two histories.
3.3 Merge¶
A merge combines the histories of two branches.
The feature branch receives the changes from main.
Existing feature commits retain their original identities.
3.4 Rebase¶
A rebase replays your feature commits on top of another branch.
Conceptually:
Before:
After:
The commits are replayed and receive new commit IDs.
Rebase creates a more linear history, but it rewrites the feature branch's history.
3.5 Conflict Resolution¶
When Git cannot automatically integrate changes, it pauses the operation.
You must:
- Inspect the affected files.
- Understand both versions.
- Decide what the final content should be.
- Remove conflict markers.
- Stage the resolved files.
- Continue the merge or rebase.
Professional recommendation: Never resolve a conflict by blindly accepting one version. Understand the intended functionality first.
4. Prepare the Training Environment¶
We'll use your existing training repository:
github-deep-dive-training
We'll simulate two developers modifying the same documentation file.
4.1 Synchronize Your Repository¶
Open PowerShell inside your repository.
Make sure your working tree is clean.
If Git reports local modifications, preserve or commit them before starting the exercise.
4.2 Create the Practice Directory¶
Our structure will be:
Create the directory:
Create the file:
4.3 Add the Initial Content¶
Open the file and add:
# Merge Conflict Practice
## Restaurant Order Status
The default order status is:
`pending`
## Business Rule
Every newly created order starts as pending.
## Responsible Team
The order management team maintains this workflow.
4.4 Commit the Initial Version¶
git add docs/github/module-03-pull-requests/conflict-practice.md
git commit -m "docs(github): add merge conflict practice"
git push origin main
We now have a common starting point for both developers.
5. Create Two Branches and Introduce Conflicting Changes¶
We'll simulate two developers working independently.
Developer A¶
Feature branch:
Developer B¶
Main branch:
Both developers will modify the same section of the same file.
5.1 Developer A Creates a Feature Branch¶
Start from the latest main:
Create the branch:
Modify conflict-practice.md:
# Merge Conflict Practice
## Restaurant Order Status
The default order status is:
`preparing`
## Business Rule
Every newly created order starts as preparing.
## Responsible Team
The kitchen team maintains this workflow.
Commit:
git add docs/github/module-03-pull-requests/conflict-practice.md
git commit -m "docs(orders): update default order status"
Do not push yet.
5.2 Developer B Modifies Main¶
Switch back to main:
Modify the same file:
# Merge Conflict Practice
## Restaurant Order Status
The default order status is:
`confirmed`
## Business Rule
Every newly created order starts as confirmed.
## Responsible Team
The cashier team maintains this workflow.
Commit and push:
git add docs/github/module-03-pull-requests/conflict-practice.md
git commit -m "docs(orders): update order confirmation status"
git push origin main
Now the branches have diverged.
Developer A has one version, while main contains another.
5.3 Inspect the Branch History¶
Run:
You should see two branches with independent commits.
This is the situation that can produce a merge conflict.
6. Reproduce and Resolve Your First Merge Conflict¶
6.1 Attempt to Merge Main¶
Switch back to Developer A's branch:
Merge the latest main:
Git should report a conflict.
You may see:
Auto-merging docs/github/module-03-pull-requests/conflict-practice.md
CONFLICT (content): Merge conflict in
docs/github/module-03-pull-requests/conflict-practice.md
Automatic merge failed; fix conflicts and then commit the result.
This is expected.
You have successfully reproduced a merge conflict.
6.2 Understand Conflict Markers¶
Open the affected file.
You should see something similar to:
[Conflict start: HEAD]
The default order status is:
`preparing`
─────────────────────
The default order status is:
`confirmed`
[Conflict end: main]
Understand each marker:
| Marker | Meaning |
|---|---|
<<<<<<< HEAD |
Beginning of the current side of the conflict. |
======= |
Separates the two versions. |
>>>>>>> main |
Beginning/end marker identifying the incoming side. |
The exact displayed branch name may differ.
During this merge:
HEADrepresents the currently checked-out feature branch.- The incoming changes come from
main.
These markers are Git's way of showing you the competing content.
6.3 Inspect the Conflict Before Resolving It¶
Run:
You should see the affected file listed as unmerged.
You can inspect the conflict using:
You can also inspect the two sides using:
git show :2:docs/github/module-03-pull-requests/conflict-practice.md
git show :3:docs/github/module-03-pull-requests/conflict-practice.md
During an unresolved merge:
- Stage 2 represents the current branch's version.
- Stage 3 represents the incoming branch's version.
These commands are useful when you need to inspect the original versions before resolving the file.
6.4 Resolve the Conflict Manually¶
Now determine the correct business requirement.
For our exercise:
- Every new order starts as
pending. - Kitchen staff move orders to
preparing. - Cashiers confirm payment.
- The order becomes
readyafter preparation.
Replace the conflicting content with:
# Merge Conflict Practice
## Restaurant Order Status
The default order status is:
`pending`
## Business Rule
1. Every newly created order starts as pending.
2. Kitchen staff move the order to preparing.
3. The cashier confirms payment.
4. The order becomes ready after preparation.
## Responsible Teams
- Kitchen team: preparation status.
- Cashier team: payment confirmation.
- Order management team: overall workflow.
Save the file.
6.5 Stage the Resolved File¶
Staging the file tells Git that you have resolved its conflict.
6.6 Verify the Resolution¶
The unmerged status should disappear.
Check whitespace problems:
Make sure the conflict markers have been removed.
6.7 Complete the Merge¶
6.8 Inspect the History¶
You should see the two histories joined by a merge commit.
6.9 Push the Feature Branch¶
You have now resolved and published your first merge conflict.
7. Resolve Conflicts Using VS Code¶
Manual conflict resolution is useful, but VS Code provides a graphical interface that makes the process easier.
7.1 Open Your Repository¶
VS Code includes built-in Git integration and a Merge Editor.
7.2 Understand the Conflict Resolution Options¶
When a conflict occurs, VS Code identifies the affected file.
Depending on the version and context, you may see options such as:
| Option | Meaning |
|---|---|
| Accept Current Change | Keep the current branch's version. |
| Accept Incoming Change | Keep the incoming branch's version. |
| Accept Both Changes | Include both versions. |
| Compare Changes | Inspect differences between versions. |
None of these options automatically guarantees the correct business outcome.
7.3 Understand Current Versus Incoming¶
Suppose the conflict contains:
If you select:
- Accept Current: keeps
preparing. - Accept Incoming: keeps
confirmed. - Accept Both: includes both versions, which may require additional editing.
Remember that accepting both changes does not necessarily produce valid documentation or application logic.
7.4 Use the Three-Way Merge Editor¶
The VS Code Merge Editor typically presents three views:
Incoming¶
Changes being merged into your branch.
Current¶
Your existing branch's content.
Result¶
The final content that will be saved.
You can select changes from either side and manually edit the result.
The exact interface can vary with VS Code versions and configuration.
7.5 Complete the Resolution¶
After editing the result:
- Save the file.
- Verify that no conflict markers remain.
- Stage the resolved file.
- Confirm Git no longer reports an unmerged file.
- Complete the merge.
Commands:
git status
git add .
git diff --check
git status
git commit -m "merge: resolve documentation conflict"
Only create the merge commit if the merge is still awaiting completion.
Exercise 1 — VS Code Conflict Resolution¶
Repeat the previous conflict exercise using VS Code instead of manually editing the conflict markers.
Your objective is to become comfortable with both approaches.
8. Abort a Merge When Necessary¶
Sometimes you start resolving a conflict and realize that you need to restart.
Git provides:
This attempts to return your working tree and index to the state before the merge started.
8.1 Practical Example¶
Start with a clean feature branch:
Attempt a merge that produces a conflict:
If you decide to cancel:
Check:
Your feature branch should return to its pre-merge state.
8.2 Merge Recovery Commands¶
| Command | Purpose |
|---|---|
git merge main |
Merge main into the current branch. |
git merge --abort |
Abort an active merge. |
git status |
Inspect the current repository state. |
git diff |
Inspect working-tree changes. |
git diff --check |
Check whitespace problems. |
git log --graph |
Inspect branch history. |
Important: Preserve unrelated uncommitted work before starting a merge. git merge --abort is not a universal recovery mechanism for every working-tree situation.
9. Update a Feature Branch From Main¶
One of the most common Pull Request maintenance tasks is keeping your feature branch synchronized with its target branch.
Imagine:
Your feature branch started from B, but main now contains C and D.
You need to update your feature branch.
There are two common approaches.
9.1 Approach A — Merge Main Into the Feature Branch¶
First:
Merge the latest remote main:
This integrates the latest main changes into your feature branch.
If conflicts occur:
- Inspect the affected files.
- Resolve the conflicts.
- Stage the resolved files.
- Complete the merge.
Then:
Advantages:
- Preserves existing feature commits.
- Does not rewrite existing feature history.
- Suitable for shared feature branches.
Disadvantages:
- May create additional merge commits.
- Can make the history more complicated.
9.2 Approach B — Rebase the Feature Branch Onto Main¶
First, ensure your working tree is clean.
Rebase:
Git replays your feature commits on top of the latest main.
If a conflict occurs:
Resolve the affected files, then stage them:
Continue:
Repeat until the rebase finishes.
If you need to cancel:
9.3 What Happens When You Rebase an Already-Pushed Branch?¶
If you have already pushed your feature branch, rebasing may change its commit IDs.
Consequently, a normal push may be rejected.
You may need:
Important:
--force-with-lease is safer than ordinary --force because it checks that the remote branch has not changed unexpectedly since your last known state.
However, it still rewrites remote history.
Use it only when you understand the consequences and have coordinated with anyone sharing the branch.
For shared feature branches, prefer avoiding unnecessary history rewriting.
9.4 Merge Versus Rebase¶
| Criteria | Merge | Rebase |
|---|---|---|
| Preserves existing commit IDs | Yes | No, replayed commits receive new IDs. |
| Creates merge commit | Sometimes | No, not for the rebase itself. |
| Produces linear history | Not necessarily | Usually |
| Rewrites feature history | No | Yes |
| Suitable for shared branches | Generally safer | Requires coordination |
| Suitable for private feature branches | Yes | Yes |
Professional recommendation:
Practise both approaches.
Use merge when preserving shared branch history is important.
Use rebase when a cleaner feature-branch history is desired and the branch is safe to rewrite.
10. Understand GitHub's Merge Conflict Indicators¶
GitHub can detect when a Pull Request cannot be merged automatically.
10.1 Inspect the Pull Request¶
Create a PR:
Open the Pull Request on GitHub.
When the branches contain unresolved merge conflicts, GitHub may display a message similar to:
Depending on the conflict type and repository configuration, GitHub may also offer a Resolve conflicts option.
10.2 Resolve Conflicts Through GitHub¶
For supported text conflicts:
- Open the Pull Request.
- Locate the merge-conflict notification.
- Select Resolve conflicts if available.
- Edit the conflicting content.
- Mark the conflict as resolved.
- Save the resolution.
- Review the updated Pull Request.
GitHub creates the corresponding resolution commit.
10.3 Understand GitHub's Limitations¶
The web conflict editor does not support every conflict type.
For example:
- Binary file conflicts.
- Some rename conflicts.
- More complicated file operations.
- Complex conflicts requiring local testing.
These situations may require local Git and an editor such as VS Code.
10.4 Recommended Resolution Method¶
| Situation | Preferred method |
|---|---|
| Simple text conflict | GitHub editor or VS Code |
| Multiple conflicting files | Local Git + VS Code |
| Complex merge | Local Git |
| Binary file conflict | Appropriate local tool |
| Shared branch with collaborators | Coordinate before rewriting history |
Exercise 2 — GitHub Conflict Indicator¶
Create a PR from your feature branch.
Then introduce a conflicting change into main using another branch or collaborator.
Inspect the PR page.
Record:
- Whether GitHub detects the conflict.
- Whether the merge button is disabled.
- Whether GitHub offers a conflict-resolution option.
- Whether the conflict can be resolved through the web interface.
- Whether additional local work is necessary.
Do not merge until the conflict is resolved and the updated changes have been reviewed.
11. What Happens to Pull Request Reviews After Updating a PR?¶
This is particularly important because you learned formal reviews in Lesson 29.
Suppose:
- Developer A opens a PR.
- Developer B reviews and approves it.
- Developer A pushes additional commits.
- The PR now contains new changes.
Should Developer B's approval still be trusted?
Not necessarily.
The reviewer should inspect the latest changes before the PR is merged.
11.1 Understand Stale Reviews¶
A stale approval is an approval that may no longer represent the latest version of the Pull Request.
For example:
Developer B approves the original implementation.
Developer A subsequently changes important application logic.
The original review may no longer be sufficient evidence that the updated implementation has been reviewed.
11.2 GitHub Review Protection Settings¶
GitHub supports repository rules and branch protection configurations that can control how approvals behave.
Examples include:
Dismiss stale pull request approvals when new commits are pushed¶
When enabled, previous approvals can be dismissed after new commits modify the PR.
Require approval of the most recent reviewable push¶
This requires an eligible approval after the latest reviewable changes are pushed.
Require a specific number of approving reviews¶
This establishes the minimum number of approvals required before merging.
These settings are not automatically enabled in every repository.
11.3 Practical Review Timeline¶
| Time | Event |
|---|---|
| 10:00 | PR opened |
| 10:30 | Developer B approves the changes. |
| 11:00 | Developer A pushes new implementation changes. |
| 11:05 | Developer B inspects the updated diff. |
| 11:20 | Developer B submits an updated approval. |
Professional practice: Always review the final diff before merging, regardless of whether an earlier approval remains technically valid.
11.4 Inspect Updated PR Changes¶
Open your PR.
Navigate to:
Files changed¶
Inspect:
- Newly added lines.
- Modified lines.
- Deleted lines.
- Changes introduced after the previous review.
- Any new files.
Also inspect the PR conversation to understand what changed after review.
12. Keep Pull Requests Healthy¶
Not every PR problem is a merge conflict.
Large, unfocused, outdated Pull Requests can also create problems.
12.1 Avoid Oversized Pull Requests¶
Bad example:
PR: Update entire restaurant application
Changes:
- 150 files
- 12 unrelated features
- 30 bug fixes
- Database redesign
- Frontend redesign
Better approach:
PR 1: Add product management API
PR 2: Add product management UI
PR 3: Add product validation tests
PR 4: Add product documentation
Separate work into manageable units when practical.
12.2 Keep Pull Requests Focused¶
A PR should ideally have one primary purpose.
For example:
Should not unexpectedly include:
- Authentication redesign.
- Docker restructuring.
- Payment changes.
- Unrelated documentation updates.
12.3 Keep PR Descriptions Updated¶
When implementation changes significantly, update the PR description.
Make sure it explains:
- What the final implementation does.
- What changed after review.
- Which tests were executed.
- Whether any limitations remain.
- Whether the original acceptance criteria were satisfied.
12.4 Understand Draft Versus Ready for Review¶
Use Draft PRs when work is incomplete.
Mark them ready for review when:
- Implementation is complete.
- Tests have been executed.
- The PR description is accurate.
- The changes are ready for independent review.
12.5 Keep Your Branch Clean¶
Before pushing:
Avoid including:
- Temporary files.
- Generated artifacts.
- Local configuration.
- Unrelated changes.
- Debugging code.
12.6 Keep PR Discussions Organized¶
After addressing review comments:
- Push the required changes.
- Reply to the relevant review comments.
- Resolve conversations when appropriate.
- Request another review if necessary.
- Confirm that the final changes satisfy the review requirements.
This connects the PR maintenance process with the review workflow from Lesson 29.
13. Git Commands Reference¶
These are the important commands from Lesson 30.
13.1 Branch Synchronization¶
| Command | Purpose |
|---|---|
git fetch origin |
Fetch remote updates without integrating them. |
git pull --ff-only origin main |
Fetch and integrate main only when fast-forward is possible. |
git merge origin/main |
Merge the latest fetched remote main. |
git rebase origin/main |
Rebase the current branch onto remote main. |
13.2 Conflict Resolution¶
| Command | Purpose |
|---|---|
git status |
Inspect the current repository state. |
git diff |
Inspect working-tree changes and conflicts. |
git diff --check |
Check whitespace problems. |
git add <file> |
Stage a resolved file. |
git merge --abort |
Abort an active merge. |
git rebase --continue |
Continue a paused rebase. |
git rebase --abort |
Abort an active rebase. |
13.3 History Inspection¶
| Command | Purpose |
|---|---|
git log --oneline |
Display compact commit history. |
git log --graph --oneline --all |
Visualize branch history. |
git branch -vv |
Display local branches and upstream tracking information. |
git show <commit> |
Inspect a particular commit. |
git diff main...feature |
Compare feature changes against the merge base with main. |
13.4 Remote Branch Updates¶
| Command | Purpose |
|---|---|
git push origin feature |
Push feature changes. |
git push --force-with-lease origin feature |
Update a remote branch after a coordinated history rewrite. |
Important: Understand the difference between git fetch, git pull, and git merge.
- Fetch downloads remote information.
- Pull fetches and integrates remote changes.
- Merge combines histories.
14. Practical Assignment — Two-Developer Merge Conflict Simulation¶
Required Exercise¶
Now complete a more realistic exercise using two independent feature branches.
Scenario¶
You're developing a restaurant order management feature.
Two developers independently modify the same documentation file.
Developer A: Changes the order lifecycle.
Developer B: Changes the order payment workflow.
Both changes must be integrated into main.
Part A — Prepare the Repository¶
Start from updated main:
Confirm a clean working tree:
Part B — Developer A Creates the Order Lifecycle Branch¶
Modify:
Change the default order status and add the lifecycle information.
Example:
## Restaurant Order Status
The default order status is:
`pending`
## Order Lifecycle
1. Order is created.
2. Kitchen starts preparation.
3. Order becomes ready.
4. Order is completed.
Commit:
git add docs/github/module-03-pull-requests/conflict-practice.md
git commit -m "feat(orders): document order lifecycle"
Do not push yet.
Part C — Developer B Creates the Payment Branch¶
Return to main:
Create:
Modify the same file.
Change the same default order status section to:
Add a payment section:
## Payment Workflow
1. Order is created.
2. Cashier confirms payment.
3. Payment status becomes paid.
4. Order proceeds through preparation.
Commit:
git add docs/github/module-03-pull-requests/conflict-practice.md
git commit -m "feat(payments): document payment workflow"
Part D — Integrate Developer B's Changes¶
Push Developer B's branch:
Create a Pull Request:
Review the changes and merge the PR.
Part E — Integrate Developer A's Changes¶
Return to Developer A's branch:
Fetch the latest remote changes:
Merge the updated main:
Because both branches modified the same section, Git should report a conflict.
Inspect the affected file.
Resolve the conflict while preserving both developers' valid changes.
The final document should contain:
- Order lifecycle.
- Payment workflow.
- Valid order statuses.
- Clear responsibilities.
- No conflict markers.
Part F — Complete Developer A's PR¶
Stage the resolved file:
Complete the merge:
Push:
Open the PR:
Review and merge it.
Part G — Verify the Final Result¶
git switch main
git pull --ff-only origin main
git log --oneline --graph --decorate --all
git status
Confirm:
- Both developers' changes exist.
- No conflict markers remain.
- Both PRs are merged.
- The working tree is clean.
15. Advanced Exercise — Compare Merge and Rebase¶
Use separate practice branches to compare the two approaches.
Do not reuse the same experiment branch for both operations.
Exercise A — Merge Strategy¶
Start from updated main:
Create:
Add:
# Merge Strategy Experiment
This file is used to practise merging feature branches.
## Strategy
Merge main into the feature branch.
Commit:
git add docs/github/module-03-pull-requests/merge-experiment.md
git commit -m "docs(github): add merge experiment"
Now make an independent change on main using another branch or collaborator.
After that change is merged:
Inspect:
Record your observations.
Exercise B — Rebase Strategy¶
Start from updated main:
Create:
Add:
# Rebase Strategy Experiment
This file is used to practise rebasing feature branches.
## Strategy
Rebase the feature branch onto the latest main.
Commit:
git add docs/github/module-03-pull-requests/rebase-experiment.md
git commit -m "docs(github): add rebase experiment"
Now introduce another independent commit on main.
Fetch and rebase:
Inspect:
Record your observations.
Compare Your Results¶
| Question | Merge | Rebase |
|---|---|---|
| Did you create a merge commit? | Record result | Record result |
| Were feature commits preserved with their original IDs? | Record result | Record result |
| Did commit IDs change? | Record result | Record result |
| Was conflict resolution necessary? | Record result | Record result |
| Which history was easier to understand? | Your conclusion | Your conclusion |
16. Repository Documentation¶
Now create the official Lesson 30 documentation.
Your repository structure should look like:
docs/
└── github/
└── module-03-pull-requests/
├── lesson-28-pr-fundamentals.md
├── lesson-29-advanced-reviews.md
├── lesson-30-merge-conflicts.md
├── conflict-practice.md
├── merge-experiment.md
└── rebase-experiment.md
Create:
Use this documentation structure:
# Lesson 30 — Merge Conflicts and PR Management
## Learning Objectives
## 1. Understanding Merge Conflicts
## 2. Fast-Forward and Non-Fast-Forward Updates
## 3. Merge vs Rebase
## 4. Training Environment Setup
## 5. Creating Two Conflicting Branches
## 6. Resolving Conflicts Manually
## 7. Resolving Conflicts in VS Code
## 8. Aborting a Merge
## 9. Updating Feature Branches
## 10. GitHub Conflict Detection
## 11. Stale Reviews and Updated PRs
## 12. Keeping Pull Requests Healthy
## 13. Git Commands Reference
## 14. Practical Conflict Simulation
## 15. Merge vs Rebase Exercise
## 16. Lessons Learned
## 17. Assessment Checklist
## 18. References
Documentation requirements:
- Include explanations, not just command lists.
- Include actual Git command examples.
- Include branch diagrams.
- Include conflict-resolution examples.
- Include screenshots from your actual exercises where useful.
- Document any unexpected errors and their solutions.
- Do not include hypothetical screenshots as evidence of completed exercises.
17. Lessons Learned and Professional Practices¶
After completing the exercises, document your conclusions.
Your documentation should explain:
- Why merge conflicts happen.
- Why editing the same file doesn't always cause a conflict.
- Why business requirements matter during conflict resolution.
- When merge is preferable to rebase.
- Why rewriting shared branch history requires coordination.
- How VS Code simplifies conflict resolution.
- How GitHub detects merge conflicts.
- Why updated Pull Requests may require another review.
- Why small, focused PRs are easier to maintain.
- How to keep a feature branch synchronized with main.
Professional Conflict-Resolution Checklist¶
Before completing a merge:
- [ ] Understand both versions.
- [ ] Confirm the intended behavior.
- [ ] Resolve every conflicting file.
- [ ] Remove all conflict markers.
- [ ] Run relevant tests.
- [ ] Check
git status. - [ ] Check
git diff --check. - [ ] Review the final changes.
- [ ] Confirm that the merge or rebase completed successfully.
18. Commit, Pull Request, Tag and Release¶
Follow your established training repository workflow.
Step 1 — Create a Documentation Branch¶
Step 2 — Add Documentation¶
Step 3 — Validate¶
Step 4 — Commit¶
Step 5 — Push¶
Step 6 — Create a Pull Request¶
PR title:
PR description:
## Summary
Add documentation covering advanced GitHub PR management and merge conflicts.
## Topics
- Merge conflict fundamentals
- Branch divergence
- Fast-forward and non-fast-forward updates
- Conflict markers
- Manual resolution
- VS Code Merge Editor
- Merge abort
- Merge vs rebase
- Feature branch synchronization
- GitHub conflict detection
- Stale reviews
- PR maintenance
## Practical exercises
- [ ] Two-branch conflict simulation
- [ ] VS Code conflict resolution
- [ ] GitHub conflict detection
- [ ] Merge experiment
- [ ] Rebase experiment
## Validation
- [ ] Markdown checked
- [ ] Commands tested
- [ ] Git history inspected
- [ ] Exercises completed
- [ ] Documentation reviewed
Review your PR and merge it into main.
Step 7 — Create an Annotated Tag¶
Switch to updated main:
Create the annotated tag:
Push:
Verify:
Step 8 — Create the GitHub Release¶
Open your repository on GitHub.
Navigate to:
Releases → Draft a new release¶
Configure:
| Field | Value |
|---|---|
| Tag | module-03-lesson-30 |
| Release title | Module 3 — Lesson 30: Merge Conflicts |
| Target | main |
Release notes:
# Module 3 — Lesson 30
Completed Pull Request Management and Merge Conflicts.
## Topics
- Merge conflict fundamentals
- Branch divergence
- Fast-forward and non-fast-forward updates
- Conflict markers
- Manual conflict resolution
- VS Code Merge Editor
- Merge abort
- Merge vs rebase
- Feature branch synchronization
- GitHub conflict detection
- Stale reviews
- PR maintenance
## Practical exercises
- Two-branch conflict simulation
- VS Code conflict resolution
- GitHub conflict detection
- Merge experiment
- Rebase experiment
## Training checkpoint
module-03-lesson-30
Publish the release.
19. Lesson 30 Assessment¶
Track your progress.
Completion checklist:
- [ ] Created two branches from a common starting point.
- [ ] Modified the same file in both branches.
- [ ] Successfully reproduced a merge conflict.
- [ ] Understood Git conflict markers.
- [ ] Resolved a conflict manually.
- [ ] Resolved a conflict using VS Code.
- [ ] Used
git merge --abort. - [ ] Updated a feature branch from main.
- [ ] Practised merging main into a feature branch.
- [ ] Practised rebasing a feature branch.
- [ ] Understood
--force-with-lease. - [ ] Inspected Git history using
git log --graph. - [ ] Created and reviewed a PR involving conflict resolution.
- [ ] Understood stale approvals and updated reviews.
- [ ] Completed the two-developer simulation.
- [ ] Completed the merge versus rebase comparison.
- [ ] Published the Lesson 30 GitHub Release.
Completion target: 17/17¶
20. Official Documentation and References¶
Bookmark these references for future use.
Git Documentation¶
- Git — git merge.
- Git — git rebase.
- Git — git merge-base.
- Git — git status.
- Git — git diff.
GitHub Documentation¶
- GitHub — Addressing merge conflicts.
- GitHub — About protected branches.
- GitHub — About pull request reviews.
VS Code Documentation¶
- VS Code — Source Control.
- VS Code — Resolving merge conflicts.
What's Next?¶
Lesson 31 — Advanced Pull Request Automation & Governance¶
Next Module Lesson¶
Lessons 28–30 established the manual Pull Request workflow:
- Lesson 28: Creating and managing Pull Requests.
- Lesson 29: Advanced Pull Request reviews.
- Lesson 30: Merge conflicts and PR maintenance.
Now we'll move beyond manually managing PRs and explore how professional teams automate and control their Pull Request workflows.
Topics in Lesson 31¶
- Advanced Pull Request templates.
- Issue forms and PR integration.
- CODEOWNERS in real projects.
- Automatic reviewer assignment.
- Branch protection rules.
- Repository rulesets.
- Required approvals and review policies.
- Required status checks.
- Auto-merge.
- Merge queues.
- Enforcing PR title conventions.
- GitHub Actions integration with PRs.
- Enforcing Conventional Commits.
- Building a professional PR governance workflow.
Our progression: Lessons 28–30 established the manual Pull Request workflow. Lesson 31 will turn that workflow into a controlled, automated process suitable for professional development teams.
Repository: github-deep-dive-training
Continue using:
- Markdown lesson documentation.
- Conventional Commits.
- Feature branches.
- Pull Requests.
- Review workflows.
- Annotated Git tags.
- GitHub Releases.