Created
March 25, 2017 06:20
-
-
Save shivamMg/5cc23be1b94a06b489ffea5e0842acf5 to your computer and use it in GitHub Desktop.
Understanding git merge --no-ff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git init | |
| echo a > a.txt | |
| git add a.txt && git commit -m "a" | |
| git checkout -b feature-b | |
| echo b > b.txt | |
| git add b.txt && git commit -m "b" | |
| git checkout master | |
| # ($) | |
| ### Two cases possible: | |
| # 1) Plain merge (will fast forward in our case) | |
| git merge feature-b | |
| git log | |
| ## <hash> b | |
| ## <hash> a | |
| # No merge commit in our case (because fast forward) | |
| # 2) No-ff Merge (will not fast forward even if it's possible (in our case it was possible)) | |
| git merge --no-ff feature-b | |
| git log | |
| ## <hash> Merge commit | |
| ## <hash> b | |
| ## <hash> a | |
| # Going back to git checkout master ($) | |
| # Let's commit some work on master | |
| echo c > c.txt | |
| git add c.txt && git commit -m "c" | |
| git merge feature-b | |
| # Now fast forward is not possible | |
| git log | |
| ## <hash> Merge commit | |
| ## <hash> c | |
| ## <hash> b | |
| ## <hash> a | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment