DEV Community

Gustavo Tavares
Gustavo Tavares

Posted on

I can Merge! (actually git did it for me)

This Weeks Goal

For this week, the goal was to choose 2 features and add it to our SSG project. GMOT-SSG
But each feature had to be in a different branch so we could have different merging experience.

Picking My Features

The features I have chosen was:
• Adding -l or –-lang feature to allow user to input the language he wants his HTML to be.

• Parsing the ‘---’ from Markdown to < hr > in HTML.

For each feature, I created an Issue in my project’s repo. The implementation of these features was fairly simple, the language feature took me about 2 or 3 lines of code to implement it and the Markdown feature only one.
Issue #12
Issue #13

For my first feature, from the main branch I created a branch with the issue number. After everything was done, I simply made a commit with the code changes. I did same for the next feature.

But the objective of this lab was not to implement more features to our project, but to make us have different branches for these features and merge them to the main.

Merging

Fast-Forward Merging

When I first merged my first branch, I got the fast forward merge, which basically just pointed the main branch to the issue branch that was being merged.
FF merge

Three-way merge

Because my first file was a fast forward merge, now my main had some code that my branch didn’t have. To deal with this problem git used the Three-way merge, where they create another commit with a mixture of my main and my branch.
3-way Merge

Pushing

After I got a message that I had no conflicts and the merge was successful, and after testing it again and again, I knew it was time to push it to my repo.
After That I closed the issues, I made with a brief description on how I did.

For Next Week

For the next week I hope to get the same experience, but with conflicts in the merge. I want to learn how to select what’s the right code for the merge.
I believe in real situation; conflicts will be way more common than we imagine and I think knowing how to deal with them it’s essential for any programmer.

Thank you for reading!

Top comments (0)