Skip to content

Commit 0b09635

Browse files
authored
Merge pull request #956 from frankier/fixup-rebase-merge-markdown
Remove unneeded/unused extra attributes on images on "Rebase vs merge post"
2 parents bde065e + 329937a commit 0b09635

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

content/blog/2020-04-24-rebase-vs-merge.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ which situations they are an advantage to use.
1919
Rebase gives you the opportunity to move the base of a branch to a new
2020
base. Here we have two branches, `master` and `feature_A`.
2121

22-
![Initial tree](/blog/image_01.png "Initial git commit tree"){:class="img-responsive" style="max-width:100%"}
22+
![Initial tree](/blog/image_01.png "Initial git commit tree")
2323

2424
We can rebase the `feature_A` branch to the last commit in `master`:
2525

@@ -31,17 +31,17 @@ git rebase master
3131
The result will look like this.
3232

3333
![First rebase tree](/blog/image_02.png "git commit tree
34-
after rebase"){:class="img-responsive" style="max-width:100%"}
34+
after rebase")
3535

3636
Checking out `master` again, we can merge `feature_A` with `master`. The merge will by default be a fast-forward. We end up with a linear history, which many find attractive as it is easy to follow. The disadvantage is that we rewrite the history as the commit hashes changes.
3737

38-
![FF-merge tree](/blog/image_03.png "git commit tree after fast-forward merge"){:class="img-responsive" style="max-width:100%"}
38+
![FF-merge tree](/blog/image_03.png "git commit tree after fast-forward merge")
3939

4040
### Merge
4141

4242
If we don’t use rebase, but just merge `feature_A` with `master`, we get an merge commit, a new commit pointing to the previous last commit in `master` and the previous last commit in `feature_A`.
4343

44-
![Plain merge tree](/blog/image_04.png "git commit tree after regular merge"){:class="img-responsive" style="max-width:100%"}
44+
![Plain merge tree](/blog/image_04.png "git commit tree after regular merge")
4545

4646
If we only do merges, we show the true story of the repository, how the code came to be. As the repository grows with new branches, maybe more contributors, following the history can become very challenging. The git graph can look like the tracks of a large railway station, where it can be hard to find the ancestors of a feature.
4747

@@ -59,7 +59,7 @@ How will this look?
5959

6060
Let us say we have created a new function or class, something that belongs together - a semantic unit we call `feature_B`. The base of `feature_B` is the last commit in `master`.
6161

62-
![Master feature-b tree](/blog/image_05.png "git commit tree with master and a new feature"){:class="img-responsive" style="max-width:70%"}
62+
![Master feature-b tree](/blog/image_05.png "git commit tree with master and a new feature")
6363

6464
If we do a merge, git will by default do a fast-forward merge. Following our newly stated policy, we want this merge to be a merge commit. Consequently, we add the option --no-ff to the merge command:
6565
```sh
@@ -74,13 +74,13 @@ git config --global branch.master.mergeoptions --no-ff
7474

7575
The result will be like this, where the feature is clearly visible in a feature path, presumably with well written commit messages explaining what has been added in this path of work.
7676

77-
![No-ff merge tree](/blog/image_06.png "git commit tree after --no-ff merge"){:class="img-responsive" style="max-width:100%"}
77+
![No-ff merge tree](/blog/image_06.png "git commit tree after --no-ff merge")
7878

7979
#### Rebase revisited
8080

8181
Now we take the case where we checkout a branch from C1 to do some corrections. While we were doing the corrections, at least before we were able to complete the corrections, `master` moved to M1 as in the picture above. A merge commit will add unnecessary complexity to the story of our project. We are not adding a new semantic unit, just fixing things that got wrong in the first phase. That we started to fix things from C1 is not necessarily a important information to keep for the project.
8282

83-
![No-ff merge tree plus patch](/blog/image_07.png "git commit tree with a merged feature branch and a patch branch in master"){:class="img-responsive" style="max-width:100%"}
83+
![No-ff merge tree plus patch](/blog/image_07.png "git commit tree with a merged feature branch and a patch branch in master")
8484

8585
Following our second principle, we rebase the fix_typos branch to M1. Then we do a merge, but this time as fast-forward. If we have configured merge for not doing fast forward when possible, as the configuration statement above, we need to add the --ff-only argument:
8686
```sh
@@ -91,7 +91,7 @@ git merge fix_typos --ff-only
9191
```
9292
The git graph will now look like this:
9393

94-
![No-ff merge plus rebase](/blog/image_08.png "git commit tree with a merged feature branch and a rebased patch branch"){:class="img-responsive" style="max-width:100%"}
94+
![No-ff merge plus rebase](/blog/image_08.png "git commit tree with a merged feature branch and a rebased patch branch")
9595

9696
### Rebase vs merge revisited
9797
Rebase and merge serve two different purposes. We can use this to our advantage to create a clear story, a more readable git log (It is important to create a story, remember?). By using the above principles as guidance, we will become more conscious of where these operations will serve us or add more clutter. For instance, we might conclude that rebasing semantic branches, but insisting on a merge commit, is perfectly fine, because it is where the feature (the semantic entity) enters the `master` branch which is important, not where the development first started. Features will clearly stand out as a visible pattern in a git repository following such a practice.

0 commit comments

Comments
 (0)