Skip to Content
Version Control with Git
book

Version Control with Git

by Jon Loeliger
June 2009
Intermediate to advanced
330 pages
9h 29m
English
O'Reilly Media, Inc.
Content preview from Version Control with Git

Merge Strategies

So far, our examples have been easy to handle because there are only two branches. It might seem like Git’s extra complexity of DAG-shaped history and long, hard-to-remember commit IDs isn’t really worth it. And maybe it isn’t, for such a simple case. But let’s look at something a little more complicated.

Imagine that instead of just one person working on in your repository, there are three. To keep things simple, suppose that each developer—Alice, Bob, and Cal—is able to contribute changes as commits on three separate eponymous branches within a shared repository.

Since the developers are all contributing to separate branches, let’s leave it up to one person, Alice, to manage the integration of various contributions. In the meantime, each developer is allowed to leverage the development of the others by directly incorporating or merging a coworker’s branch, as needed.

Eventually, the coders develop a repository with a commit history as shown in Figure 9-1.

Criss-cross merge setup

Figure 9-1. Criss-cross merge setup

Imagine that Cal started the project and Alice joined in. Alice worked on it for a while, then Bob joined in. In the meantime, Cal has been working away on his own version.

Eventually, Alice merged in Bob’s changes, and Bob kept on working without merging Alice’s changes back into his tree. There are now three different branch histories as shown in Figure 9-2.

Figure 9-2. After Alice ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Version Control with Git, 2nd Edition

Version Control with Git, 2nd Edition

Jon Loeliger, Matthew McCullough
Version Control with Git, 3rd Edition

Version Control with Git, 3rd Edition

Prem Kumar Ponuthorai, Jon Loeliger
Git for Programmers

Git for Programmers

Jesse Liberty

Publisher Resources

ISBN: 9780596158187Errata