Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Francesco Menghi
Francesco Menghi

Posted on • Edited on

     

Dealing with Merge Conflicts

This week I continued learning Git by practicing creating branches and merging them back to main.

In my Static Site Generatorstatic-dodo, I added two new issues, one toAdd support for inline code blocks and the other toAdd 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 inparallel. After adding the necessary code to both branches, I decided to usegit merge to merge both back into main.

git merge issue-13 main

The first one was an easyfast-forward merge. This means that theHEAD of main is simply moved to the latestcommit in issue-13.

git merge issue-14 main

This second one created aconflict. 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:

<<<<<<< HEADLine from main branch=======Line from issue-14 branch>>>>>>> issue-14
Enter fullscreen modeExit fullscreen mode

This time all I wanted to do was to keep both lines, so I simply deleted the<<<<<<<,=======,>>>>>>> lines. Here is the mergecommit.


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 startHacktoberfest and I hope to find some good projects to contribute to!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Location
    Toronto, Canada
  • Joined

More fromFrancesco Menghi

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp