DEV Community

Qiwen Yu
Qiwen Yu

Posted on

Discuss on Github Branch Merge

I'm gonna talk about Github branch merging today.

When working on a project through Github, one necessary step is to know how to create multiple branches to work on new features and work on multiple code changes in parallel on separate topic branches.

I have picked two small feature changes to my repository. First of all, I created two issues to my repo. And I created two new topic branches to these two issues, which you can find in issue-06 and issue-07. Then the next step is to implement the features I picked in order to fix the issues.

The first feature I decided to change is to add an optional -l, --lang, and/or \l flag, which indicates the language to use when generating the lang attribute on the root element. For example, --lang fr would mean that the HTML documents are in French, and would include , while -l pt-BR would mean the text is using Brazilian Portuguese: .
By default, use en-CA for Canadian English.

The second feature is an improvement to the project. If there are no errors, exit with 0. Otherwise, exit with a non-zero exit code (e.g., -1).

After all the code is done, it is the time to merge the features to the branch. Starting by switching to the default branch and merge the first feature branch. In my case, is to merge the issue-06 to main branch. The first merge is a "fas- forward" merge using git merge issue-06 command.
Alt Text
The second merge will also use the same command, but in Git, the second command is doing a "three-way recursive merge"
Alt Text

When all the features are implemented, it's time to push them as usual, and then close the issues.

After this whole process of dealing with git merge, I had a better understanding with how to collaborating your code to open source projects, where there are always multiple contributors to work on the project.

Discussion (0)