Diferență între revizuiri ale paginii „SDPT Lab 2”

De la WikiLabs
Jump to navigationJump to search
(Pagină nouă: = Lab 2: Multi-Player Git, Merge Requests, and Conflict Resolution = == Introduction == In Week 1, you learned how to drive Git in "single-player mode." You initialized a reposito...)
 
 
Linia 1: Linia 1:
= Lab 2: Multi-Player Git, Merge Requests, and Conflict Resolution =
+
= Lab 2: Multi-Player Git, Code Reviews, and Advanced Conflict Resolution =
  
 
== Introduction ==
 
== Introduction ==
In Week 1, you learned how to drive Git in "single-player mode." You initialized a repository, staged files, and pushed to your own remote server.  
+
In Week 1, you learned how to drive Git in "single-player mode." Today, we switch to "multi-player mode." Software engineering is a team sport. When multiple engineers edit the same codebase simultaneously, collisions are inevitable, and uninterrupted work is a myth.  
  
Today, we switch to "multi-player mode." Software engineering is a team sport. When multiple engineers edit the same codebase simultaneously, collisions are inevitable. By the end of this 2-hour lab, you and a partner will have:
+
By the end of this 2-hour lab, you and your partner will have:
# Configured a shared team repository.
+
# Configured a shared team repository with strict Branch Protection.
# Enforced Trunk-Based Development by locking down the <code>main</code> branch.
+
# Used <code>git stash</code> to handle an emergency "hotfix" interruption.
# Worked in parallel on feature branches.
+
# Conducted an iterative Code Review (requesting and pushing fixes).
 
# Intentionally caused a Git Merge Conflict.
 
# Intentionally caused a Git Merge Conflict.
# Resolved the conflict using Git commands and GitLab Merge Requests (MRs).
+
# Resolved the conflict professionally using <code>git rebase</code> and force-pushing.
# Conducted a formal Code Review.
 
  
 
'''Requirement:''' Find a partner. Decide who will be '''Student A (The Maintainer)''' and who will be '''Student B (The Developer)'''.
 
'''Requirement:''' Find a partner. Decide who will be '''Student A (The Maintainer)''' and who will be '''Student B (The Developer)'''.
Linia 17: Linia 16:
  
 
== Part 1: Team Setup and Branch Protection (20 Minutes) ==
 
== Part 1: Team Setup and Branch Protection (20 Minutes) ==
We must first create a shared workspace and establish our "Traffic Laws" (Branch Protection).
+
We must first create a shared workspace and establish our "Traffic Laws."
  
 
=== 1. Create the Shared Repository (Student A) ===
 
=== 1. Create the Shared Repository (Student A) ===
Linia 23: Linia 22:
 
* Uncheck "Initialize repository with a README".
 
* Uncheck "Initialize repository with a README".
 
* On the left sidebar, go to '''Manage''' -> '''Members'''.
 
* On the left sidebar, go to '''Manage''' -> '''Members'''.
* Click '''Invite members'''. Search for '''Student B''' by their university email or username.
+
* Click '''Invite members'''. Search for '''Student B''' by their university email.
 
* Assign Student B the role of '''Developer''' and click Invite.
 
* Assign Student B the role of '''Developer''' and click Invite.
  
 
=== 2. Enforce Branch Protection (Student A) ===
 
=== 2. Enforce Branch Protection (Student A) ===
We are using Trunk-Based Development. The <code>main</code> branch is sacred. No one should be allowed to push broken code directly to it.
+
The <code>main</code> branch is sacred. No one should be allowed to push code directly to it.
 
* '''Student A:''' In the project sidebar, go to '''Settings''' -> '''Repository'''.
 
* '''Student A:''' In the project sidebar, go to '''Settings''' -> '''Repository'''.
 
* Expand the '''Protected branches''' section.
 
* Expand the '''Protected branches''' section.
Linia 34: Linia 33:
 
* Set '''Allowed to push and merge''' to: <code>No one</code>.
 
* Set '''Allowed to push and merge''' to: <code>No one</code>.
 
* Click '''Protect'''.  
 
* Click '''Protect'''.  
''(Now, the ONLY way code gets into main is through a Merge Request!)''
 
  
 
=== 3. Initialize the Baseline (Student A) ===
 
=== 3. Initialize the Baseline (Student A) ===
Student A will push the initial skeleton code so you both have a starting point.
+
Student A will push the initial skeleton code.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
# Student A's Terminal:
 
 
mkdir sdpt-lab2-collaboration
 
mkdir sdpt-lab2-collaboration
 
cd sdpt-lab2-collaboration
 
cd sdpt-lab2-collaboration
Linia 45: Linia 42:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Create a file named <code>main.cpp</code>:
+
Create <code>main.cpp</code>:
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
 
#include <iostream>
 
#include <iostream>
Linia 54: Linia 51:
  
 
int main() {
 
int main() {
     std::cout << "System Booting..." << std::endl;
+
     std::cout << "Sytem Booting..." << std::endl; // Notice the typo!
 
     init_hardware();
 
     init_hardware();
 
     return 0;
 
     return 0;
Linia 69: Linia 66:
  
 
=== 4. Clone the Repository (Student B) ===
 
=== 4. Clone the Repository (Student B) ===
* '''Student B:''' Go to Student A's GitLab project page. Copy the SSH clone URL.
+
* '''Student B:''' Copy the SSH clone URL from GitLab.
* Open your terminal and clone the shared repository to your machine:
+
* Clone the repository to your machine:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone git@gitlab.com:<Student-A-Username>/sdpt-lab2-collaboration.git
 
git clone git@gitlab.com:<Student-A-Username>/sdpt-lab2-collaboration.git
Linia 78: Linia 75:
 
---
 
---
  
== Part 2: Parallel Realities (30 Minutes) ==
+
== Part 2: The Emergency Interruption & Stash (20 Minutes) ==
Both students will now create isolated branches and attempt to implement the hardware initialization logic at the exact same time.
+
Student B is going to start working on a feature, but Student A (acting as the manager) will interrupt them with an urgent bug fix.
  
=== 1. Branching Out (Both Students) ===
+
=== 1. Start Feature Work (Student B) ===
Both students must run the following commands on their own machines:
+
* '''Student B:''' Create a branch for the I2C driver.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
# Student A runs:
+
git checkout -b feature-i2c
git checkout -b feature-spi-init
 
 
 
# Student B runs:
 
git checkout -b feature-i2c-init
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
Open <code>main.cpp</code> and replace the TODO comment:
=== 2. Writing the Code (Both Students) ===
 
Open <code>main.cpp</code> in your text editor. Find the <code>init_hardware()</code> function.
 
 
 
'''Student A (SPI Logic):''' Replace the TODO comment with this exact code:
 
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
 
void init_hardware() {
 
void init_hardware() {
     std::cout << "Initializing SPI Bus on Port A..." << std::endl;
+
     std::cout << "Initializing I2C Bus on Port B..." << std::endl;
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
''Wait! Do not commit yet!''
  
'''Student B (I2C Logic):''' Replace the TODO comment with this exact code:
+
=== 2. The Emergency (Student A) ===
<syntaxhighlight lang="cpp">
+
* '''Student A:''' "Stop what you are doing! There is a typo in the main boot message ('Sytem Booting'). We need a hotfix immediately!"
void init_hardware() {
+
 
    std::cout << "Initializing I2C Bus on Port B..." << std::endl;
+
=== 3. The Stash (Student B) ===
}
+
Student B cannot switch to the <code>main</code> branch because they have uncommitted I2C changes. They must stash them.
 +
<syntaxhighlight lang="bash">
 +
git stash
 +
git checkout main
 +
git checkout -b hotfix-typo
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== 3. Commit and Push (Both Students) ===
+
=== 4. Fix the Bug (Student B) ===
Because you are on separate branches, you can both push to the server safely.
+
Open <code>main.cpp</code> and fix the typo to say <code>"System Booting..."</code>.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
# Student A:
 
 
git add main.cpp
 
git add main.cpp
git commit -m "Add SPI hardware initialization"
+
git commit -m "Fix typo in boot message"
git push -u origin feature-spi-init
+
git push -u origin hotfix-typo
 +
</syntaxhighlight>
 +
* '''Student B:''' Go to GitLab, open a Merge Request for the hotfix, and assign Student A.
 +
* '''Student A:''' Review the MR, Approve it, and click '''Merge'''.
  
# Student B:
+
=== 5. Resume Work (Student B) ===
 +
Student B, now that the emergency is handled, return to your feature and pop your stash.
 +
<syntaxhighlight lang="bash">
 +
git checkout feature-i2c
 +
git stash pop
 +
</syntaxhighlight>
 +
Your I2C code has returned! Commit and push it.
 +
<syntaxhighlight lang="bash">
 
git add main.cpp
 
git add main.cpp
 
git commit -m "Add I2C hardware initialization"
 
git commit -m "Add I2C hardware initialization"
git push -u origin feature-i2c-init
+
git push -u origin feature-i2c
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
Open a Merge Request for <code>feature-i2c</code>.
=== 4. Open Merge Requests (Both Students) ===
 
* Both students: Go to the GitLab project page.
 
* You should see a blue banner saying "You pushed to feature-...". Click '''Create merge request'''.
 
* Assign your partner as the '''Reviewer'''.
 
* Click '''Create merge request'''.
 
  
 
---
 
---
  
== Part 3: The Collision & Code Review (30 Minutes) ==
+
== Part 3: Parallel Dev & Iterative Code Review (25 Minutes) ==
Right now, both Merge Requests look green and ready to merge. Git doesn't know there is a problem yet.  
+
While Student B was working, Student A was supposed to be writing the SPI driver.
  
=== 1. Review and Merge Student A's Code ===
+
=== 1. Create the Collision (Student A) ===
* '''Student B:''' Go to the Merge Requests tab and click on Student A's MR (SPI init).
+
* '''Student A:''' Make sure you are on <code>main</code> and pull the latest changes (the typo fix).
* Go to the '''Changes''' tab to review the code.
+
<syntaxhighlight lang="bash">
* Leave a comment on the line of code: "Looks good, SPI is the correct protocol."
+
git checkout main
* Click '''Approve''', then click the green '''Merge''' button.
+
git pull origin main
 +
git checkout -b feature-spi
 +
</syntaxhighlight>
 +
Open <code>main.cpp</code> and edit the EXACT SAME LINE that Student B edited:
 +
<syntaxhighlight lang="cpp">
 +
void init_hardware() {
 +
    std::cout << "Initializing SPI Bus on Port A..." << std::endl;
 +
}
 +
</syntaxhighlight>
 +
Commit, push, and open an MR.
 +
<syntaxhighlight lang="bash">
 +
git add main.cpp
 +
git commit -m "Add SPI hardware initialization"
 +
git push -u origin feature-spi
 +
</syntaxhighlight>
  
Student A's code is now officially part of the <code>main</code> branch!
+
=== 2. The Iterative Review ===
 +
* '''Student A:''' Go to Student B's Merge Request (the I2C one).
 +
* Do '''NOT''' approve it. We are going to request a change.
 +
* Go to the '''Changes''' tab. Click the comment bubble next to the I2C line and write: ''"We need to specify the baud rate here. Please add 'at 400kHz' to the output."'' Click '''Start a review''' and then '''Submit review'''.
  
 +
=== 3. Implementing the Fix (Student B) ===
 +
* '''Student B:''' You received a change request. Update your code locally.
 +
<syntaxhighlight lang="cpp">
 +
void init_hardware() {
 +
    std::cout << "Initializing I2C Bus on Port B at 400kHz..." << std::endl;
 +
}
 +
</syntaxhighlight>
 +
<syntaxhighlight lang="bash">
 +
git add main.cpp
 +
git commit -m "Update I2C init to include baud rate per code review"
 +
git push origin feature-i2c
 +
</syntaxhighlight>
 +
* Notice that your GitLab MR automatically updates!
 +
* '''Student A:''' Check the MR again. The requested change is there. Click '''Approve''' and '''Merge'''.
  
=== 2. The Conflict Appears ===
+
---
* '''Student B:''' Go back to the Merge Requests list and open your own MR (I2C init).
 
* You will see a glaring error: '''Merge blocked: merge conflicts must be resolved.'''
 
* ''Why did this happen?'' Both of you edited the exact same line in <code>main.cpp</code>. Git refuses to guess whether the SPI code or the I2C code should win. A human must intervene.
 
  
---
+
== Part 4: The Rebase Conflict (25 Minutes) ==
 +
Because Student B's MR was merged first, Student A's MR (SPI) is now broken.
  
== Part 4: Resolving the Conflict (30 Minutes) ==
+
=== 1. Discovering the Conflict (Student A) ===
Student B must pull the new changes from the server and fix the conflict locally before they can merge.
+
* '''Student A:''' Check your <code>feature-spi</code> Merge Request on GitLab. You will see a red warning: '''Merge blocked: merge conflicts must be resolved.'''
  
=== 1. Update the Local Main Branch (Student B) ===
+
=== 2. Fetch and Rebase (Student A) ===
Student B, your local machine does not know about Student A's merged code yet.
+
We will resolve this using the professional Trunk-Based standard: Rebasing.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
# Switch back to main
+
# Download the latest state of the remote server
git checkout main
+
git fetch origin
  
# Download the latest changes from the server
+
# Replay your SPI commits on top of the newly updated main branch
git pull origin main
+
git rebase origin/main
</syntaxhighlight>
 
 
 
=== 2. Rebase or Merge? (Student B) ===
 
Switch back to your feature branch. We need to integrate the new <code>main</code> into your feature branch. We will use a merge to resolve the conflict.
 
<syntaxhighlight lang="bash">
 
git checkout feature-i2c-init
 
git merge main
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
Git will stop and output: <code>CONFLICT (content): Merge conflict in main.cpp.</code>
  
Git will output: <code>CONFLICT (content): Merge conflict in main.cpp. Automatic merge failed.</code>
+
=== 3. Fix the Code (Student A) ===
 
+
Open <code>main.cpp</code>. You will see the Git markers.
=== 3. Fix the Code (Student B) ===
 
Open <code>main.cpp</code> in your text editor. Git has injected markers into your code:
 
 
 
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
 
void init_hardware() {
 
void init_hardware() {
 
<<<<<<< HEAD
 
<<<<<<< HEAD
     std::cout << "Initializing I2C Bus on Port B..." << std::endl;
+
     std::cout << "Initializing I2C Bus on Port B at 400kHz..." << std::endl;
 
=======
 
=======
 
     std::cout << "Initializing SPI Bus on Port A..." << std::endl;
 
     std::cout << "Initializing SPI Bus on Port A..." << std::endl;
>>>>>>> main
+
>>>>>>> Add SPI hardware initialization
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
Delete the markers and combine the code so BOTH interfaces initialize:
 
 
* '''Task:''' Discuss with Student A. Decide that you actually need ''both'' protocols to initialize.
 
* Delete the Git markers (<code><<<<<<<</code>, <code>=======</code>, <code>>>>>>>></code>) and combine the logic so it looks like this:
 
 
 
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
 
void init_hardware() {
 
void init_hardware() {
 +
    std::cout << "Initializing I2C Bus on Port B at 400kHz..." << std::endl;
 
     std::cout << "Initializing SPI Bus on Port A..." << std::endl;
 
     std::cout << "Initializing SPI Bus on Port A..." << std::endl;
    std::cout << "Initializing I2C Bus on Port B..." << std::endl;
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== 4. Finalize the Merge (Student B) ===
+
=== 4. Continue and Force Push (Student A) ===
Now that the conflict is manually fixed, tell Git it is resolved:
+
Stage the resolved file and tell the rebase to continue.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git add main.cpp
 
git add main.cpp
git commit -m "Resolve merge conflict between SPI and I2C initialization"
+
git rebase --continue
git push origin feature-i2c-init
+
</syntaxhighlight>
 +
Because rebasing rewrites history, your local branch and the remote branch have diverged. A normal <code>git push</code> will fail. You must force it.
 +
<syntaxhighlight lang="bash">
 +
git push --force origin feature-spi
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== 5. Final Approval (Student A) ===
+
=== 5. Final Approval (Student B) ===
* '''Student A:''' Go to Student B's Merge Request on GitLab.  
+
* '''Student B:''' Go to Student A's MR. The conflict is gone!  
* Notice the conflict warning is gone. The MR is green again!
+
* Review the code, click '''Approve''', and click '''Merge'''.
* Review the Changes to ensure both SPI and I2C are initialized.
 
* Click '''Approve''', then click '''Merge'''.
 
  
 
---
 
---
  
 
== Lab Deliverable ==
 
== Lab Deliverable ==
To receive full credit for this week's lab, both partners must call the professor or teaching assistant over to your workstation and demonstrate:
+
To receive full credit for this week's lab, call the professor or TA over and demonstrate:
# The shared GitLab repository showing the <code>main</code> branch with both SPI and I2C logic combined.
+
# Your GitLab MR history showing '''three''' merged requests (Hotfix, I2C, SPI).
# The '''Settings -> Repository -> Protected branches''' screen showing that <code>main</code> cannot be pushed to directly.
+
# Inside the I2C MR, show the comment thread where a change was requested and resolved.
# The '''Merge Requests''' tab showing two Closed/Merged MRs with review comments visible.
+
# Run <code>git log --graph --oneline</code> on your terminal to prove the final history includes all features without broken code.
# Run <code>git log --graph --oneline</code> on your terminal to show the visual graph of the diverging branches and the merge commit.
 

Versiunea curentă din 2 martie 2026 14:11

Lab 2: Multi-Player Git, Code Reviews, and Advanced Conflict Resolution

Introduction

In Week 1, you learned how to drive Git in "single-player mode." Today, we switch to "multi-player mode." Software engineering is a team sport. When multiple engineers edit the same codebase simultaneously, collisions are inevitable, and uninterrupted work is a myth.

By the end of this 2-hour lab, you and your partner will have:

  1. Configured a shared team repository with strict Branch Protection.
  2. Used git stash to handle an emergency "hotfix" interruption.
  3. Conducted an iterative Code Review (requesting and pushing fixes).
  4. Intentionally caused a Git Merge Conflict.
  5. Resolved the conflict professionally using git rebase and force-pushing.

Requirement: Find a partner. Decide who will be Student A (The Maintainer) and who will be Student B (The Developer).

---

Part 1: Team Setup and Branch Protection (20 Minutes)

We must first create a shared workspace and establish our "Traffic Laws."

1. Create the Shared Repository (Student A)

  • Student A: Log into GitLab and create a new blank project named sdpt-lab2-collaboration.
  • Uncheck "Initialize repository with a README".
  • On the left sidebar, go to Manage -> Members.
  • Click Invite members. Search for Student B by their university email.
  • Assign Student B the role of Developer and click Invite.

2. Enforce Branch Protection (Student A)

The main branch is sacred. No one should be allowed to push code directly to it.

  • Student A: In the project sidebar, go to Settings -> Repository.
  • Expand the Protected branches section.
  • Ensure the branch is set to main (or master).
  • Set Allowed to merge to: Developers + Maintainers.
  • Set Allowed to push and merge to: No one.
  • Click Protect.

3. Initialize the Baseline (Student A)

Student A will push the initial skeleton code.

mkdir sdpt-lab2-collaboration
cd sdpt-lab2-collaboration
git init

Create main.cpp:

#include <iostream>

void init_hardware() {
    // TODO: Initialize communication protocol
}

int main() {
    std::cout << "Sytem Booting..." << std::endl; // Notice the typo!
    init_hardware();
    return 0;
}

Commit and push:

git add main.cpp
git commit -m "Initial baseline code"
git remote add origin git@gitlab.com:<Student-A-Username>/sdpt-lab2-collaboration.git
git push -u origin main

4. Clone the Repository (Student B)

  • Student B: Copy the SSH clone URL from GitLab.
  • Clone the repository to your machine:
git clone git@gitlab.com:<Student-A-Username>/sdpt-lab2-collaboration.git
cd sdpt-lab2-collaboration

---

Part 2: The Emergency Interruption & Stash (20 Minutes)

Student B is going to start working on a feature, but Student A (acting as the manager) will interrupt them with an urgent bug fix.

1. Start Feature Work (Student B)

  • Student B: Create a branch for the I2C driver.
git checkout -b feature-i2c

Open main.cpp and replace the TODO comment:

void init_hardware() {
    std::cout << "Initializing I2C Bus on Port B..." << std::endl;
}

Wait! Do not commit yet!

2. The Emergency (Student A)

  • Student A: "Stop what you are doing! There is a typo in the main boot message ('Sytem Booting'). We need a hotfix immediately!"

3. The Stash (Student B)

Student B cannot switch to the main branch because they have uncommitted I2C changes. They must stash them.

git stash
git checkout main
git checkout -b hotfix-typo

4. Fix the Bug (Student B)

Open main.cpp and fix the typo to say "System Booting...".

git add main.cpp
git commit -m "Fix typo in boot message"
git push -u origin hotfix-typo
  • Student B: Go to GitLab, open a Merge Request for the hotfix, and assign Student A.
  • Student A: Review the MR, Approve it, and click Merge.

5. Resume Work (Student B)

Student B, now that the emergency is handled, return to your feature and pop your stash.

git checkout feature-i2c
git stash pop

Your I2C code has returned! Commit and push it.

git add main.cpp
git commit -m "Add I2C hardware initialization"
git push -u origin feature-i2c

Open a Merge Request for feature-i2c.

---

Part 3: Parallel Dev & Iterative Code Review (25 Minutes)

While Student B was working, Student A was supposed to be writing the SPI driver.

1. Create the Collision (Student A)

  • Student A: Make sure you are on main and pull the latest changes (the typo fix).
git checkout main
git pull origin main
git checkout -b feature-spi

Open main.cpp and edit the EXACT SAME LINE that Student B edited:

void init_hardware() {
    std::cout << "Initializing SPI Bus on Port A..." << std::endl;
}

Commit, push, and open an MR.

git add main.cpp
git commit -m "Add SPI hardware initialization"
git push -u origin feature-spi

2. The Iterative Review

  • Student A: Go to Student B's Merge Request (the I2C one).
  • Do NOT approve it. We are going to request a change.
  • Go to the Changes tab. Click the comment bubble next to the I2C line and write: "We need to specify the baud rate here. Please add 'at 400kHz' to the output." Click Start a review and then Submit review.

3. Implementing the Fix (Student B)

  • Student B: You received a change request. Update your code locally.
void init_hardware() {
    std::cout << "Initializing I2C Bus on Port B at 400kHz..." << std::endl;
}
git add main.cpp
git commit -m "Update I2C init to include baud rate per code review"
git push origin feature-i2c
  • Notice that your GitLab MR automatically updates!
  • Student A: Check the MR again. The requested change is there. Click Approve and Merge.

---

Part 4: The Rebase Conflict (25 Minutes)

Because Student B's MR was merged first, Student A's MR (SPI) is now broken.

1. Discovering the Conflict (Student A)

  • Student A: Check your feature-spi Merge Request on GitLab. You will see a red warning: Merge blocked: merge conflicts must be resolved.

2. Fetch and Rebase (Student A)

We will resolve this using the professional Trunk-Based standard: Rebasing.

# Download the latest state of the remote server
git fetch origin

# Replay your SPI commits on top of the newly updated main branch
git rebase origin/main

Git will stop and output: CONFLICT (content): Merge conflict in main.cpp.

3. Fix the Code (Student A)

Open main.cpp. You will see the Git markers.

void init_hardware() {
<<<<<<< HEAD
    std::cout << "Initializing I2C Bus on Port B at 400kHz..." << std::endl;
=======
    std::cout << "Initializing SPI Bus on Port A..." << std::endl;
>>>>>>> Add SPI hardware initialization
}

Delete the markers and combine the code so BOTH interfaces initialize:

void init_hardware() {
    std::cout << "Initializing I2C Bus on Port B at 400kHz..." << std::endl;
    std::cout << "Initializing SPI Bus on Port A..." << std::endl;
}

4. Continue and Force Push (Student A)

Stage the resolved file and tell the rebase to continue.

git add main.cpp
git rebase --continue

Because rebasing rewrites history, your local branch and the remote branch have diverged. A normal git push will fail. You must force it.

git push --force origin feature-spi

5. Final Approval (Student B)

  • Student B: Go to Student A's MR. The conflict is gone!
  • Review the code, click Approve, and click Merge.

---

Lab Deliverable

To receive full credit for this week's lab, call the professor or TA over and demonstrate:

  1. Your GitLab MR history showing three merged requests (Hotfix, I2C, SPI).
  2. Inside the I2C MR, show the comment thread where a change was requested and resolved.
  3. Run git log --graph --oneline on your terminal to prove the final history includes all features without broken code.