Introduction
In the world of coding, Git conflicts are like roadblocks that every developer encounters at some point. Recently, I faced one such hiccup while working on the txtToWeb.py script. This story is about how I navigated the challenge, resolving the conflict, and what I learned in the process.
Background and Implementation
As a part of Lab 3, I implemented two additional features in two different branches my txtToWeb tool as discussed in previous blogs.
- issue-9 : This branch a lang flag implemented based on which my html lang was set.
- issue-10 : This branch had a parses implemented for
---
to convert it to<hr>
tags.
Link to the issues created to track the above : #9 #10
The Merge Attempt
I was merging changes from two branches, issue-9
and issue-10
, into the main code. Things seemed smooth until Git hit a snag and flagged a conflict in the txtToWeb.py file. It meant lines of code from both branches clashed, creating confusion.
Fast-Forward Merge
The first merge for merging issue-9
was straightforward a fast-forward type of merge as it directly had the main branch as the parent and I just used the command below to make the changes.
git merge issue-9
Recursive Merge
With the first merge done, I proceeded to merge issue-10. However, this time, Git didn’t play nice. The conflict arose in the txtToWeb.py file, halting my progress. Lines of code from both branches were entangled, and Git was waiting for my decision on which changes to keep. It required me to commit my changes again in order to merge the last branch. The special thing about this type of merge is that It has two parent commits.
Committing Changes: Handling the Dual Parent Commits
Once I resolved the conflict and edited the code accordingly, there was a unique step in the process. In a recursive merge, Git requires an additional commit to finalize the merge, especially when there are two parent commits. This step ensured that both branches' changes were properly integrated.
Learning Outcome from the Lab
I faced an issue that it failed to open vi editor. After consulting with my professor, He guided me to change my default git editor using the command below:
git config --global core.editor "vim"
I also learned how to handle both type of git merges and how to handle few conflicts related to recursive merges.
Another important thing I learned is using git status
to debug when in middle of a conflicting merge.
Top comments (0)