Journeying through Git Merging
So this week Prof H's has got us experimenting with multiple branches for our program and merging them altogether. The first part of the task seemed simple enough, the features that were required were not that much of a headache to code. The real challenge here is merging 3 branches altogether that's been coded separately. It just seems like the more you learn about git, the more you realise you barely understand it. And that was the challenge this week with the merge feature.
The final merge tree of this whole debacle |
So I created 2 different branches and went to work on adding the features. I added an option to the CLI program that would output a json array of the URLs and their status' And in the other branch I added another option, of 3 different flags that would filter the url outputs based on their results. Once I was done with these commits, it was time to merge them.
Merging the first issue was fine, because it was essentially a fast-forward merge, but a little note, I made a readme edit on the master branch so technically it was a recursive merge, but no conflicts were found because it was 2 different files that were changed on both commits. The next merge with the other branch however had a conflict. I was stumped for a while, because I was trying to understand how what it was, how to fix it and what caused it. Well, through excessive amounts of googling and Prof's extremely helpful lecture on git merging, I realised that the 2 branches had changes that were in the same line. Remember when I mentioned that both issues were just adding option features? Well it had me code both issues on the yargs variable, and it did not help that all those option were of the boolean type. The line that specified the type was what caused the anomaly as seen on the screenshot here
The way that git merge works is that it looks for differences in lines of code and that last line for the options seemed to match the code in 2 different ways through merging the branches
Comments
Post a Comment