DEV Community

Mayank Kumar
Mayank Kumar

Posted on

Understanding Git Merge

As I'm continuing my journey in open source software development, everyday brings a new challenge and learning experience. In this blog post, I'll share my experience working on two branches in parallel, for these two issues: issue-15 and issue-16, within my dev-mate-cli project. Along the way, I'll discuss the changes I made, the challenges I faced, and the lessons I learned about the merging process.

Branching Out: Creating issue-15 and issue-16

For this project, I created two issues on my repository and then created two branches locally to implement distinct features:

  1. issue-15: This branch focused on adding folder processing capabilities to the application. This feature was crucial for allowing users to input entire directories, enabling a more efficient workflow.

  2. issue-16: In this branch, I aimed to add a stream flag that would allow the application to stream responses to stdout. This enhancement would improve real-time output handling, making the application more responsive.

I made a conscious effort to minimize changes across both branches to avoid potential merge conflicts. This approach was informed by a previous experience in which working in parallel branches led to complex merges. With this understanding, I aimed for a smoother merging process this time around.

Making Changes: Implementing Features

In the issue-15 branch, I focused on developing the folder processing feature. This involved modifying the file-handling logic to accept and process multiple files within a specified directory. I wanted to add this feature to make file inputs easier for the user.

Simultaneously, in the issue-16 branch, I worked on implementing the stream flag. This feature required adjustments to how the application managed output, allowing it to stream responses in real-time using Open AI's Chat Completion API. I incorporated command-line options to enable or disable this functionality, providing users with added flexibility.

Merging the Branches

Once I completed the features in both branches, it was time to merge them back into the main branch. The final commits for both branches can be checkout out here - issue-15(https://github.com/mayank-Pareek/dev-mate-cli/commit/3abdc216e53975bd539290e048eed0c501323aa6), issue-16(https://github.com/mayank-Pareek/dev-mate-cli/commit/7b0cd68b64bc74d184838ab19ae6a0a7779282c2).

The process began by ensuring that both branches were up to date with the latest changes from the main branch. I did this by running:

git checkout main
git pull origin main
Enter fullscreen mode Exit fullscreen mode

Next, I merged each feature branch into the main branch sequentially. First, I merged issue-15:

git checkout main
git merge issue-15
Enter fullscreen mode Exit fullscreen mode

The merging process was smooth, and I successfully integrated the changes without any conflicts. I then proceeded to merge issue-16 in the same manner:

git merge issue-16
Enter fullscreen mode Exit fullscreen mode

Lessons Learned and Future Improvements

As I learned from my previous pull requests, minimizing changes in parallel branches can significantly reduce the potential for conflicts. Understanding what to change and what to leave alone is vital. I also explored more of Git’s branching and merging capabilities, which are really powerful tools. Embracing these features and learning how to manage them effectively can lead to a smoother development process.

Working with parallel branches in Git has been a rewarding learning experience. By creating new branches for new feature, I was able to implement significant features while successfully merging them back into the main branch without any issues. As I continue to grow as a developer, I will carry these lessons with me for more efficient collaboration in future projects.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up