This week I continued learning Git by practicing creating branches and merging them back to main.
In my Static Site Generator static-dodo, I added two new issues, one to Add support for inline code blocks and the other to Add support for a horizontal rule in Markdown.
Instead of working on these issues in the main branch one by one, I created a branch for each and started working on these in parallel. After adding the necessary code to both branches, I decided to use git merge
to merge both back into main.
git merge issue-13 main
The first one was an easy fast-forward merge. This means that the HEAD of main is simply moved to the latest commit in issue-13.
git merge issue-14 main
This second one created a conflict. The reason is that on the same line where I added code for issue 13, I also wrote code for issue 14.
Git in this case put it all together while adding these helpful lines to the file:
<<<<<<< HEAD
Line from main branch
=======
Line from issue-14 branch
>>>>>>> issue-14
This time all I wanted to do was to keep both lines, so I simply deleted the <<<<<<<
, =======
, >>>>>>>
lines. Here is the merge commit.
This was a simple exercise but it made me realize how powerful Git can be and I still feel like I have only scratched the surface of it. I am now getting ready to start Hacktoberfest and I hope to find some good projects to contribute to!
Top comments (0)