{"thread":{"id":"46709","subject":"git merge algorithm question","startedAt":"2017-09-06T00:54:07Z","lastAt":"2017-09-06T01:43:47Z","messageCount":2,"participants":["Daniel Biran","Bryan Turner"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"327619","messageId":"92605DF3-9274-45A6-88B7-6281D192203F@google.com","threadId":"46709","inReplyTo":"202EE2E2-1D0B-4772-85F7-7C7804905297@google.com","subject":"git merge algorithm question","fromName":"Daniel Biran","fromEmail":"dbiran@google.com","sentAt":"2017-09-06T00:53:59Z","receivedAt":"2017-09-06T00:54:07Z","isPatch":false,"sender":{"key":"dbiran@google.com","avatar":null},"body":"\n>> I'm trying to better understand one of the merge algorithms as I had some triumphs and tribulations with using a set of commands during a merge. tldr: can a git merge -s recursive -X patience; // result in a fast-forward merge? will --no-ff stop it\n>> \n>> So, the scenario is this:\n>> \t- Merging a master branch into a feature branch that is 2+ years old\n>> \t- We found this command was more beneficial when merging a large 20k line text file: \n>> \t\t- git merge -s recursive -X patience master\n>> \t- In a recent merge using this approach the reflog shows that the merge was performed using a fast-forward from the feature branch's head\n>> \t\t- 082517-1, feature/branch) HEAD@{23}: merge feature/branch: Fast-forward\n>> \n>> \n>> My question is, is it possible for that command to use a fast-forward like this? (or did something else go horribly wrong? possibly an atlassian git GUI tool corrupting the work):\n>> \t- If it is possible for the command to fast-forward the merge when making the commit does --no-ff force the command to never use fast-forward in this case\n>> \n>> Thanks for the help,\n>> Daniel\n> \n\n"},{"id":"327624","messageId":"CAGyf7-EVoqV8VCvnpmGivvuQ7MHN2X2mPG7ioAWouGEtAh-ibA@mail.gmail.com","threadId":"46709","inReplyTo":"92605DF3-9274-45A6-88B7-6281D192203F@google.com","subject":"Re: git merge algorithm question","fromName":"Bryan Turner","fromEmail":"bturner@atlassian.com","sentAt":"2017-09-06T01:43:41Z","receivedAt":"2017-09-06T01:43:47Z","isPatch":false,"sender":{"key":"bturner@atlassian.com","avatar":"https://gravatar.com/avatar/16bcf3167981c1ef7c804e502642366d888a35b0d0b0a4ca01fdc442aa1acb1e?d=mp&s=160"},"body":"On Tue, Sep 5, 2017 at 5:53 PM, Daniel Biran <dbiran@google.com> wrote:\n>\n>>> I'm trying to better understand one of the merge algorithms as I had some triumphs and tribulations with using a set of commands during a merge. tldr: can a git merge -s recursive -X patience; // result in a fast-forward merge? will --no-ff stop it\n>>>\n>>> So, the scenario is this:\n>>>      - Merging a master branch into a feature branch that is 2+ years old\n>>>      - We found this command was more beneficial when merging a large 20k line text file:\n>>>              - git merge -s recursive -X patience master\n>>>      - In a recent merge using this approach the reflog shows that the merge was performed using a fast-forward from the feature branch's head\n>>>              - 082517-1, feature/branch) HEAD@{23}: merge feature/branch: Fast-forward\n>>>\n>>>\n>>> My question is, is it possible for that command to use a fast-forward like this? (or did something else go horribly wrong? possibly an atlassian git GUI tool corrupting the work):\n>>>      - If it is possible for the command to fast-forward the merge when making the commit does --no-ff force the command to never use fast-forward in this case\n\nUnless you specify --no-ff, git merge is always free to create a\nfast-forward \"merge\", even when you request the recursive strategy\nexplicitly:\n\n$ git init recursive-merge\nInitialized empty Git repository in C:/Temp/recursive-merge/.git/\n\n$ cd recursive-merge/\n\n$ echo \"Test\" > file.txt\n\n$ git add file.txt\n\n$ git commit -m \"Initial commit\"\n[master (root-commit) ad48617] Initial commit\n 1 file changed, 1 insertion(+)\n create mode 100644 file.txt\n\n$ git checkout -b feature-branch\nSwitched to a new branch 'feature-branch'\n\n$ echo \"Edit\" >> file.txt\n\n$ git commit -am \"Feature branch change\"\n[feature-branch b226557] Feature branch change\n 1 file changed, 1 insertion(+)\n\n$ git checkout master\nSwitched to branch 'master'\n\n$ git merge -s recursive -X patience feature-branch\nUpdating ad48617..b226557\nFast-forward\n file.txt | 1 +\n 1 file changed, 1 insertion(+)\n\nWith --no-ff:\n\n$ git reset --hard ad48617\nHEAD is now at ad48617 Initial commit\n\n$ git merge --no-ff -s recursive -X patience feature-branch\nMerge made by the 'recursive' strategy.\n file.txt | 1 +\n 1 file changed, 1 insertion(+)\n\nWith fast-forwarding disabled, you can see the recursive strategy is\nused as requested.\n\n>>>\n>>> Thanks for the help,\n>>> Daniel\n>>\n>\n"}]}