Why is this merge not redirected?

From the Git Book:

"if the current branch has not deviated from the other - so that every commit present in the current branch is already contained in another - then Git simply does a fast forward"

I am trying to reproduce this scenario, but this does not lead to a quick jump forward:

$ git init
Initialized empty Git repository in /work/fun/git_experiments/.git/
$ echo initial > readme && git add readme && git commit -a -m Created
[master (root-commit) 74495b9] Created
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 readme
$ git branch b1
$ echo modified > readme && git commit -a -m "Modified"
[master d40d5fb] Modified
 1 files changed, 1 insertions(+), 1 deletions(-)
$ git checkout b1
Switched to branch 'b1'
$ echo modified > readme && git commit -a -m "Modified"
[    b1 46fd337] Modified
 1 files changed, 1 insertions(+), 1 deletions(-)
$ git merge master
Merge made by recursive.
$ 
+3
source share
3 answers

Because, although the contents of the two commits are the same, they are not actually the same commit (NB: one is commit ID d40d5fb, and the other - 46fd337). Thus, the branch b1does not contain a commit in master, so not all commits in b1are descendants master.

+4
source

, . d40d5fb 46fd337, , . - , , .

, -, .

0

I think I understand:

$ git checkout master
Switched to branch 'master'
$ git merge b1
Updating d40d5fb..fd337c3
Fast-forward
$ 

When I merge the changes into master, it quickly redirects because the same exact commit just happened on b1 ..., while my example was not really the same commit.

0
source

All Articles