title: GIT merge --no-ff
body: <p>In this post I will someone expert on git try to explain how git merge --no-ff can help us. I have read here <a href="http://nvie.com/posts/a-successful-git-branching-model/" rel="nofollow noreferrer">http://nvie.com/posts/a-successful-git-branching-model/</a> (which I personally found to be a really good post) that git merge --no-ff: "This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature". So I found it really useful and make some experiments.</p>
  
  <p>The problem is about how can we know from the git log information which commits belong to each feature. For that I did the next experiment. Suppose two users are developing on a software project two different and independent feature (to avoid merge conflicts). From the last stable version we will proceed as this:</p>
  
  <p><code>
  git init
  touch AAA.txt
  git add AAA.txt 
  git commit -m "My stable software version"
  //this will simulate our project repository
  </code></p>
  
  <p>So from this point the two user (name Alice and Bob) create two different branches and start working on the features:</p>
  
  <p><code>
  git branch  feature1_Alice
  git branch  feature2_Bob
  </code> 
  And now Alice and Bob start working and commiting simultaneously. We could simulate his as:</p>
  
  <p><code>
  git checkout feature1_Alice
  touch f1_A1.txt
  git add f1_A2.txt
  git commit -m "Solving little bug on feature 1"
  </code>
  Bob do two commits following timeline after Alice does this one:</p>
  
  <p><code>git checkout feature2_Bob
   touch f2_B1.txt
   git add f2_B1.txt
   git commit -m "Starting feature 2"
   touch f2_B2.txt
  git add f2_B2.txt
  git commit -m "feature 2: implementing new functionality"
  </code>
  Then Alice finish feature:</p>
  
  <p><code>
  git checkout feature1_Alice
  touch f2_A3.txt
  git add f2_A3.txt
  git commit -m "Feature 1 finished"
  </code></p>
  
  <p>Then Bob finishes feature2:</p>
  
  <p><code>
  git checkout feature2_Bob
  touch f1_A3.txt
  git add f1_A3.txt
  git commit -m "Feature 2 finished"
  </code></p>
  
  <p>Now we merge the new feature to the main branch:</p>
  
  <p><code>
  git checkout master
  git log
  </code>
  Output:</p>
  
  <p>commit c58dd35054f83c089292d090781438f37feeffa3</p>
  
  <p>Author: Juan </p>
  
  <p>Date:   Tue Apr 25 10:30:01 2017 +0200</p>
  
  <pre><code>My stable software version
  </code></pre>
  
  <p><code>
  git merge --no-ff feature1_Alice
  //We put a message on the created commit
  </code></p>
  
  <p>Now git log outputs:</p>
  
  <p>commit 50c5d1570fe0c047f72200bd57ef6cef6fa9077e
  Merge: c58dd35 c136a23
  Author: juan
  Date:   Tue Apr 25 10:48:12 2017 +0200</p>
  
  <pre><code>Merging feature 1 to main
  Merge branch 'feature1_Alice'
  </code></pre>
  
  <p>commit c136a23c49c546e5f48d9d0634e9bc51d67370cd
  Author: juan
  Date:   Tue Apr 25 10:41:49 2017 +0200</p>
  
  <pre><code>Feature 1 finished
  </code></pre>
  
  <p>commit c9dbb1b49444555fca528f562d3a38143fd521e9
  Author: juan
  Date:   Tue Apr 25 10:35:24 2017 +0200</p>
  
  <pre><code>Solving little buf on feature 1
  </code></pre>
  
  <p>commit 58afad2b46565e614a99d94d1e1aa1c8520f9f2b
  Author: juan
  Date:   Tue Apr 25 10:35:01 2017 +0200</p>
  
  <pre><code>Starting feature 1
  </code></pre>
  
  <p>commit c58dd35054f83c089292d090781438f37feeffa3
  Author: juan
  Date:   Tue Apr 25 10:30:01 2017 +0200</p>
  
  <pre><code>My stable software version
  </code></pre>
  
  <p>And finally merge feature 2:</p>
  
  <p><code>
  git merge --no-ff feature2_Bob
  git log
  </code>
  commit 3f27f78fefb30080ace629e561a242a4f8dbca56
  Merge: 50c5d15 2eee0c1
  Author: juan
  Date:   Tue Apr 25 10:54:20 2017 +0200</p>
  
  <pre><code>Merging feature 2 to master
  Merge branch 'feature2_Bob'
  </code></pre>
  
  <p>commit 50c5d1570fe0c047f72200bd57ef6cef6fa9077e
  Merge: c58dd35 c136a23
  Author: juan
  Date:   Tue Apr 25 10:48:12 2017 +0200</p>
  
  <pre><code>Merging feature 1 to main
  Merge branch 'feature1_Alice'
  </code></pre>
  
  <p>commit 2eee0c1bb732443ae7d6f4893d651abfd558d55a
  Author: juan
  Date:   Tue Apr 25 10:43:14 2017 +0200</p>
  
  <pre><code>Feature 2 finished
  </code></pre>
  
  <p>commit c136a23c49c546e5f48d9d0634e9bc51d67370cd
  Author: juan
  Date:   Tue Apr 25 10:41:49 2017 +0200</p>
  
  <pre><code>Feature 1 finished
  </code></pre>
  
  <p>commit cd3bee2906e02df22866ba710891d21eaebb8013
  Author: juan
  Date:   Tue Apr 25 10:40:12 2017 +0200</p>
  
  <pre><code>feature 2: implementing new functionality
  </code></pre>
  
  <p>commit c6fdf092b2645f7d4088f9f439e820a9a820b891
  Author: juan
  Date:   Tue Apr 25 10:37:39 2017 +0200</p>
  
  <pre><code>Starting feature 2
  </code></pre>
  
  <p>commit c9dbb1b49444555fca528f562d3a38143fd521e9
  Author: juan
  Date:   Tue Apr 25 10:35:24 2017 +0200</p>
  
  <pre><code>Solving little buf on feature 1
  </code></pre>
  
  <p>commit 58afad2b46565e614a99d94d1e1aa1c8520f9f2b
  Author: juan
  Date:   Tue Apr 25 10:35:01 2017 +0200</p>
  
  <pre><code>Starting feature 1
  </code></pre>
  
  <p>commit c58dd35054f83c089292d090781438f37feeffa3
  Author: juan
  Date:   Tue Apr 25 10:30:01 2017 +0200</p>
  
  <pre><code>My stable software version
  </code></pre>
  
  <p>Could anyone tel how can I see from the commit history and merge commit which commits influence each feature? I cannot see the advantage commented in that web when we insert alternative commits from different features (or from a feature and master) in time. </p>
  
  <p>The only difference in using --no-ff is that the merge commit have information of which commits have been merged, but that is unseful for tracking the commit history.</p>
  
  <p>Thanks in advance.</p>