DEV Community

Cover image for Learning to merge different branches
Hung Nguyen
Hung Nguyen

Posted on

Learning to merge different branches

This week I have learnt a new git feature which was merging. In more details, I have worked with parallel branches, one for adding -l flag and the other was updating the Markdown support function.

Firstly, I created a new function to add the -l,--lang flag to my project. This flag will allow the users to modify the lang="" in the html tag. For example:

osdssg -i hello.txt -l fr
Enter fullscreen mode Exit fullscreen mode

My program will create a new html file with

<html lang="fr">

Another new feature is if users input a markdown file, my tool now can convert any --- into hr tag.

---This text is in markdown file
Enter fullscreen mode Exit fullscreen mode

Will be converted into

<hr /><p>This text is in markdown file</p>
Enter fullscreen mode Exit fullscreen mode

I did not have really important issues, but I did remove some redundant codes from previous weeks such as some testing console.log or some comments.

When I did the merging, my 2 branches were merged smoothly without any conflict. But I would like to practice more on this feature, so I added some console.log tests on both branches in order to have the conflict. Yeah, the Git complained about the conflict, I did some changes and finally I push every thing to the main.

Final thought
This feature is really interesting since it helps you well when you work as a team or if you work with the same project with different tasks. However, I think this week's lab is not enough for me to learn the merging of Git. Probably in the future, I need to separate the branches in my projects so that I can see more problem then I can learn more.

Project repo:
Final merge main with issue-11:
Final merge main with issue-12:

Top comments (2)

mhalano profile image
Marcos Alano • Edited

How did you do the merge? I read you did it, but you didn't say how.

nguyenhung15913 profile image
Hung Nguyen

Hi Alano, I should have clarified more the method and command lines I used. Thanks for your feedbacks.