Merging Branches
Tags: beginners, opensource, javascript
Published: 2022-09-28 23:40:09

Today, I'm just going to talk about what it's like to merge branches using Git.
Git is a wonderful tool that helps you manage your repo. You can switch back and forth between different snapshots of your code you made for each thing you want to add/change and work on them separately. Once you are good, you can combine/merge them back to your main snapshot. A snapshot is called a **commit**, and it and the history of commits leading up to it is a **branch**.

## The Workflow
To address two changes I wanted to add to [the static site generator](https://github.com/cychu42/staticSiteCon) I talked about in previous posts, I first opened one issue for each: [1](https://github.com/cychu42/staticSiteCon/issues/11) [2](https://github.com/cychu42/staticSiteCon/issues/12)
Then, I made a branch to work on for each them: [1](https://github.com/cychu42/staticSiteCon/commit/f46ef487ade5707492ef6e7adbe13ec49c1b0325) [2](https://github.com/cychu42/staticSiteCon/commit/e97e20898ec87231d7afaead04340cb9356ec5ad)
Spoiler: I did merge them back to the main branch, as you can see!

Once I'm satisfied with the work, I merge them back to the main branch.  If there's any conflict, git would put some **conflict markers** for me to address before continuing. Basically, if it doesn't know which version of the code to keep, it will do that for me to decide. Luckily, it's pretty smart. However, I did some testing just in case. I mean, that's the safe thing to do. And no, everything turned out to be fine thanks to how smart it is.

## What are these changes?
Just read the links...I'm kidding.
The first change was adding support to allow language selection for the HTML output files.
I added the option `-l` or `--lang` to allow users to specify what language they want to use.
This will decide the lang attribute in the HTML output file. For example, `-l pt-BR` will indicate the file is in Brazilian Portuguese, and it will have `<html lang="pt-BR">` in the HTML code.
The default would be Canadian English: `<html lang="en-CA">`

_Changes_
- Added code to allow and recognize `-l` /  `--lang` option.
- Added a variable to hold the language value, with `en-CA` as default.

<hr>

The second change was adding support for horizontal rule in Markdown input files. Essentially, this allows the tool to parse `---` in Markdown files and convert them to `<hr>` tags in the HTML output files.

_Changes_
- Added code for file writing to replace `---` or longer variations with  `<hr>` tags in the HTML output files.
- Added code to ignore lines made of tags, such as `<hr>`. (Only `<hr>` for now.)

<hr>

For both, I updated the `README.md` and help option to let users know these are part of the tool.

## Problem And Learning
I forgot to include some of the text explanation for the changes I made in README.md and the help option, when I merge the branches. I ended up adding them afterwards. I should probably remember to include them in the future for organization sake. Other than that, it's mostly stopping myself from wanting to edit a lot of things at once and sticking to the focus of each branch. Sometime, I just see some code or slight formatting issues that I want to edit right there. Hey, I managed, and this teaches me to note things down to address separately.