DEV Community

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

Posted on

3 2

Learning to merge different branches

Overview
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

Issues
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: https://github.com/nguyenhung15913/OSD600-SSG
Issue-11: https://github.com/nguyenhung15913/OSD600-SSG/issues/12
Final merge main with issue-11: https://github.com/nguyenhung15913/OSD600-SSG/commit/c9f72f123133250897eef3e27a0f5c0df3e3145d#diff-e8ba56b7852a747928456dd8ad6bc1c92a747d806b5feb04e59563044567484c
Issue-12:https://github.com/nguyenhung15913/OSD600-SSG/issues/13
Final merge main with issue-12: https://github.com/nguyenhung15913/OSD600-SSG/commit/72efea5358c4b1423e1b7394d286b225930dc785#diff-e8ba56b7852a747928456dd8ad6bc1c92a747d806b5feb04e59563044567484c

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (2)

Collapse
 
mhalano profile image
Marcos Alano • Edited

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

Collapse
 
nguyenhung15913 profile image
Hung Nguyen

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

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post