@@ -6,42 +6,43 @@ This exercise will help you practice working with Git branches, merging, and han
Steps
Step 1: Fork and Clone the Repository
Fork the Repository: Go to the repository's web page and fork it to your account.
Clone the Repository: Copy the URL of your fork, then clone it to your local machine.
Navigate into the Repository: Move into the directory of the cloned repository.
Step 2: Check Your Current Branch
Use Git to list the available branches and see which branch you’re currently on.
Step 2: Use Terminal to see which branch you’re currently on.
Step 3: Switch to feature-1 Branch
Switch to feature-1,feature-2 and explore the contents. You should find main.cpp with a message specific to this branch.
Step 3: Switch to feature-1,feature-2. You should find main.cpp with a message specific to this branch.
Step 4: Merge feature-1 into main
Switch back to main: Change to the main branch.
Merge feature-1: Merge the feature-1 branch into main.
Push the Changes: If the merge completes without conflict, push your updates to your remote repository.
Step 4: Switch back to main: Change to the main branch. Merge the feature-1 branch into main. If the merge completes without conflict, push your updates to your remote repository.
Step 5: Merge feature-2 into main (Expect Conflict)
Switch to main: Make sure you’re on the main branch.
Attempt to Merge feature-2: When you try to merge feature-2, a conflict will occur in main.cpp because both branches modified the same lines.
Step 5: Attempt to Merge feature-2: When you try to merge feature-2, a **conflict will occur** in main.cpp because both branches modified the same lines.
Step 6: Resolve the Conflict
Open main.cpp: In your text editor, you’ll see conflict markers indicating the conflicting sections.
Manually Resolve the Conflict: Choose how to combine or select the changes. Remove the conflict markers and save the resolved file.
Mark the Conflict as Resolved: Add the resolved file and commit the changes to complete the merge.
Step 6: Open main.cpp: In your text editor (VS Code), you’ll see conflict markers indicating the conflicting sections.
Manually Resolve the Conflict: **Choose to combine changes** .
Add the resolved file and commit the changes to complete the merge.
Step 7: Push the Final Merged Branch
Push the completed merge to the remote repository so that main reflects both feature branches.
Step 7: Push the completed merge to the remote repository so that main reflects both feature branches.
Step 8: Verify Your Work
Check the history to confirm that both feature-1 and feature-2 were successfully merged without any unresolved conflicts.
Step 8: Check the history to confirm that both feature-1 and feature-2 were successfully merged without any unresolved conflicts.
Your final main.cpp should look like this before the final commit
// main.cpp
#include <iostream>
int main() {
<<<<<<< HEAD
std::cout << "This is Feature 1's version" << std::endl;
=======
std::cout << "This is Feature 2's version" << std::endl;