Learning Library

← Back to Library

Continuous Integration Prevents Merge Hell

Key Points

  • Continuous integration (CI) is often misinterpreted, but fundamentally it aims to prevent the “merge hell” that arises from infrequent, large code merges.
  • In the traditional workflow, developers work on isolated features for weeks or months, leading to complex merge conflicts and bugs when their changes finally converge.
  • CI mitigates these issues by having developers submit small, functional changes to source control frequently, ensuring everyone builds on the latest codebase.
  • This frequent integration dramatically lowers the chance of overlapping edits, makes any conflicts easy to resolve promptly, and keeps the overall system stable.

Full Transcript

# Continuous Integration Prevents Merge Hell **Source:** [https://www.youtube.com/watch?v=1er2cjUq1UI](https://www.youtube.com/watch?v=1er2cjUq1UI) **Duration:** 00:06:13 ## Summary - Continuous integration (CI) is often misinterpreted, but fundamentally it aims to prevent the “merge hell” that arises from infrequent, large code merges. - In the traditional workflow, developers work on isolated features for weeks or months, leading to complex merge conflicts and bugs when their changes finally converge. - CI mitigates these issues by having developers submit small, functional changes to source control frequently, ensuring everyone builds on the latest codebase. - This frequent integration dramatically lowers the chance of overlapping edits, makes any conflicts easy to resolve promptly, and keeps the overall system stable. ## Sections - [00:00:00](https://www.youtube.com/watch?v=1er2cjUq1UI&t=0s) **Misconceptions of Continuous Integration** - Eric Minick explains how the traditional practice of developers working in isolation and merging code only after weeks or months creates painful merge conflicts, clarifying the real purpose and benefits of continuous integration. - [00:03:04](https://www.youtube.com/watch?v=1er2cjUq1UI&t=184s) **Frequent Integration to Avoid Merge Hell** - The speaker recommends merging code often to eliminate merge conflicts and employing continuous‑integration automation that builds, tests, and instantly alerts the team whenever a change breaks the code. ## Full Transcript
0:00Hi, I'm Eric Minick with IBM Cloud. 0:02I want to tell you a little bit about continuous integration today. 0:05This is a development practice 0:07that just about everybody thinks they're doing, 0:09but it's widely misunderstood. 0:11So, I want to start by talking about the bad old days before we had it, 0:16what problem we're trying to solve, 0:18and what this does for us and what it's really about. 0:22So, let's start with our old school approach 0:28where we've got a couple of developers, 0:31they're probably on a team of 30 or 50, 0:34we got Alice and Bob and they're working on their own features, 0:40and they're going to keep separate on their own features for a long time. 0:45They're writing some bits of new code here. 0:49Maybe they're deleting a line of code here or there, what have you. 0:56And their plan is that they're going to get their features to work against the code base, 1:02then in a couple of weeks, or months, later 1:05they're going to integrate their work together. 1:08They're going to merge their work together. 1:10They're going to say: 1:11"My code, your code, it's got to come together, it's all got to work". 1:15Now, in this world, 1:17you could have a situation where Alice & Bob, they changed the same line of code here, right? 1:23And maybe Alice changed this code, but then Bob deleted it. 1:29And so, this gets really awkward, really fast when you just try to algorithmically combine it. 1:36You get what's known as a merge conflict. 1:38This gets worse because it might be that some code up here, 1:44interferes with some code down here, 1:46they just don't work together and you've got bugs. 1:48And this will happen here within just one file, 1:52but in the real world, 1:54it's not just two developers working on the same file 1:57it's thousands of files, or millions, in an application. 2:02There's tens of developers involved 2:04and they're doing this over weeks and weeks. 2:07And so, reconciling all of these problems, it's big mess. 2:11It's called "merge hell". 2:13And so, they say, "What do we do to avoid merge hell? This is how we got here". 2:18Well, we start, and we'll have Alice writing some code again, right? 2:23Alice writes her code. 2:25Cool. As soon as she has something that works even a little bit, her feature is not done, 2:31but she's got code that works, it doesn't break things. 2:35She submits that in the source control, Bob pulls down the same code 2:39before he starts working, right? 2:41He always is working off the latest. 2:43Alice is always submitting hers in. 2:45Bob makes his change right? 2:47Maybe he deletes a line of code, great. 2:52Alice comes back, she's working another part of a feature, she's working on another feature, 2:57she grabs Bob's code. Cool. 3:00And now they're working on these things together. 3:04And the likelihood that they're both working on the same thing, at the same time, 3:08and that they conflict is pretty small. 3:11And if they do hit that, it's all on code they've worked on in the last day, right? 3:17they can sit together, they can reconcile this thing, it's no big deal. 3:21And so, the core principle that we're seeing here, 3:26one of my favorite things in software development, because it is so counterintuitive, 3:31is that if it hurts, do it often and it won't hurt so much. 3:35And that helps us get rid of the big, big bogey here, right? 3:41Which is, we're going to not have merge hell. 3:47We don't like merge hell. Get rid of that. 3:50OK, so that's fix number one. 3:53Now, this does create a new problem though, right? 3:57They have a whole bunch of people constantly checking in code into the code base. 4:03Things are going to break, right? 4:05It's not going to compile. 4:07There's going to be bugs that weren't there yesterday. 4:11And you have this kind of, "continuous integration led to continuously broken" problem. 4:17And that's sad. So, what do we do? 4:19Well, we put some automation in, right? 4:21And it's always watching the code. 4:25Keeping an eye on it, 4:27and whenever a change happens, 4:29It says, "OK, let me grab that code. I'm going to build it." 4:38"And then I'm going to test it." 4:40"Alright, I'm going to run my unit tests". 4:42So, if there's any change, build it, test it. 4:46If anything in here fails, then we email the team. 4:51We let Alice, Bob, the whole team know, say 4:54"Hey, there were 2 new changes since last time I did a build, 4:58looks like both Alice and Bob touched this thing. 5:02It's broken now. They need to go fix the code base." 5:05Good. So, now we've got a safety net that enables continuous integration. Good. 5:11The other thing that we're getting though, is that we always have this build. Right? 5:18So, whenever the test team wants to go test it in more depth, 5:22to run a heavier level of tests than the unit testing that we're doing here, 5:27they've got a build they know compiles - 5:29and it's the newest stuff, right? 5:32So, that's our other key benefit coming out of continuous integration 5:36is that we always have a testable build. 5:41So, there you go. 5:42Continuous integration was addressing the old way of infrequent integration, 5:48saying, "If it hurts, we're going to do it continuously, we're going to do it a lot." 5:52That avoids merge hell, keeps our developers productive, 5:56and it gives us a constantly testable build. 6:00So that's continuous integration in a nutshell. 6:03Thank you. 6:04If you have questions, please drop us a line. 6:07If you want to see more videos like this in the future, be sure to like and subscribe.