From e7f5a69951e22cc8cdf8ab51fe019b45d94c76ca Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 28 Jan 2022 16:44:01 +0100 Subject: Published rebase time travel story --- git_rebase_illustrated_with_time_travel-1.png | Bin 0 -> 1899 bytes git_rebase_illustrated_with_time_travel-2.png | Bin 0 -> 2616 bytes git_rebase_illustrated_with_time_travel-3.png | Bin 0 -> 2219 bytes git_rebase_illustrated_with_time_travel-4.png | Bin 0 -> 2467 bytes git_rebase_illustrated_with_time_travel-5.png | Bin 0 -> 3119 bytes git_rebase_illustrated_with_time_travel.html | 56 ++++++++++++++++++++++++++ index.html | 2 + 7 files changed, 58 insertions(+) create mode 100644 git_rebase_illustrated_with_time_travel-1.png create mode 100644 git_rebase_illustrated_with_time_travel-2.png create mode 100644 git_rebase_illustrated_with_time_travel-3.png create mode 100644 git_rebase_illustrated_with_time_travel-4.png create mode 100644 git_rebase_illustrated_with_time_travel-5.png create mode 100644 git_rebase_illustrated_with_time_travel.html diff --git a/git_rebase_illustrated_with_time_travel-1.png b/git_rebase_illustrated_with_time_travel-1.png new file mode 100644 index 0000000..df1ec17 Binary files /dev/null and b/git_rebase_illustrated_with_time_travel-1.png differ diff --git a/git_rebase_illustrated_with_time_travel-2.png b/git_rebase_illustrated_with_time_travel-2.png new file mode 100644 index 0000000..f0042ca Binary files /dev/null and b/git_rebase_illustrated_with_time_travel-2.png differ diff --git a/git_rebase_illustrated_with_time_travel-3.png b/git_rebase_illustrated_with_time_travel-3.png new file mode 100644 index 0000000..fdff17e Binary files /dev/null and b/git_rebase_illustrated_with_time_travel-3.png differ diff --git a/git_rebase_illustrated_with_time_travel-4.png b/git_rebase_illustrated_with_time_travel-4.png new file mode 100644 index 0000000..d3bab7d Binary files /dev/null and b/git_rebase_illustrated_with_time_travel-4.png differ diff --git a/git_rebase_illustrated_with_time_travel-5.png b/git_rebase_illustrated_with_time_travel-5.png new file mode 100644 index 0000000..3f5d437 Binary files /dev/null and b/git_rebase_illustrated_with_time_travel-5.png differ diff --git a/git_rebase_illustrated_with_time_travel.html b/git_rebase_illustrated_with_time_travel.html new file mode 100644 index 0000000..ebfc19f --- /dev/null +++ b/git_rebase_illustrated_with_time_travel.html @@ -0,0 +1,56 @@ + + + + + + + + + +Git Rebase Illustrated With Time Travel + + + +
+

Git Rebase Illustrated With Time Travel

+

Published on 2022-01-28 16:43:00+01:00 +

Back in the office days, colleagues and I would have weekly discussions about git which usually ended with comparing +merge to rebase or with me preaching about the dangers of rewriting the history. Let's go back to these times but with +a slight twist. There's already plenty of other in-depth git tutorials and git-rebase(1) is great and you should +read it. There is no point in creating yet another resource, so instead let's make it a fun and chill weekend read. +

Let's say two different people are working on two completely disconnected task in parallel in a known period. These +tasks can be divided into a sequence of sub-tasks, where each sub-tasks enables next sub-task to be performed and there +is no room for parallelization (for now). This situation can be illustrated like this:

+original timeline +

In the graph A and B lanes represent the progress of a task with significant points +in sub-tasks. All sub-tasks can be projected into the time line and their order remains the same. +

Let's expand the example by adding two common spots in time for both tasks: first being someone ordering to perform +both tasks, and second being the merge of both lanes into one.

+timeline with common tasks +

This should look somehow similar to you, because (if not for the missing middle part) this graph represents a regular +workflow that uses git-merge(1). C is a common origin and goal for both task lanes and serves +the same purpose as master branch. +

In order to reduce the number of lanes we can let one of the tasks claim the main lane for their own. This happens +when you branch off an active branch that gets some additional work done before you merge back into it:

+branch off and back +

This image was probably recognized by you right away. +

Now, it just happened, but turns out that by the end of the A task the person responsible for it +built a time machine and proposed to the project management to use it in order to perform both tasks sequentially but in +parallel time. They were as confused as you are but gave green light just to see what happens. +

Developer took the results of B with them and went back in time to the spot where A +and B diverged. They started to work on A using the souvenir from the future as the +base. People that were working on task B in the meantime were confused. +

When the moment for merge came, the traveller from future just presented their work and said that it's already +merged, so there's no need to do anything. And they spoke truthfully, because in linear time the work looked like this: +

+rebase in linear timeline +

But from the perspective of the traveller the whole timeline got distorted and didn't look linear at all:

+rebase in non-linear timeline +

From this point of view the sequence is one-lane and completely undisturbed. On the other time the timeline gets +shifted and some parts of it fade away as they never were or are no longer observed by the time traveller. +

All of this happens every time you rebase your branches. +

I hope you had fun and if you actually had some problems imagining what rebase does, I hope this post at least +pointed you in the right direction. +

Who knows maybe next time I'll write about more history rewriting shenanigans. +

+ diff --git a/index.html b/index.html index f187dd2..dc2497f 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,8 @@

Blog