After establishing Markdown support for my static site generator (SSG), I decided to enable parsing Markdown horizontal rules along with HTML document language support. However, I developed the two features on separate branches this time, so I could switch between the two if I encountered any obstacle. Little did I know the obstacle was awaiting me at the end.
Merge conflict
The first feature poses a higher risk of breaking the system because it requires more changes to the codebase. With a view to avoiding any last-minute fixes, I decided to tackle it first on issue-14
branch. Contrary to my expectation, it didn't take long to enable HTML document language support. After ensuring the changes didn't break anything, I managed to commit them and (fast-forward) merged it (using git merge
) without any additional issue.
How I resolved it
Nevertheless, I got a merge conflict after completing the second feature. As I committed it on issue-15
branch and attempted to merge the branch into main
branch, I realized there was an overlap between the two branches in the README.md
file.
Git didn't know which version it should select between the two. Luckily, I could resolve that merge conflict quite easily thanks to Visual Studio Code (VSCode). Upon viewing the file in VSCode, I was prompted to choose how the merge conflict should be resolved. Something like this:
Since I wanted to include both changes, I selected the Accept Both Changes
option and committed the merge. The two features were finally integrated into the system! 🥳
Conclusion
Merge conflicts may crop up while you are working on parallel branches. However, I think the key to resolving them is to be aware of how the tools (such as Git and VSCode) work and avoid making a lot of irrelevant changes.
Top comments (0)