{"thread":{"id":"20318","subject":"merge confusion","startedAt":"2009-07-31T12:35:54Z","lastAt":"2009-10-28T15:43:53Z","messageCount":5,"participants":["thepurpleblob","Allen Johnson","Sean Estabrooks","Tim Mazid","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"119264","messageId":"24755682.post@talk.nabble.com","threadId":"20318","inReplyTo":null,"subject":"merge confusion","fromName":"thepurpleblob","fromEmail":"howardsmiller@googlemail.com","sentAt":"2009-07-31T12:35:54Z","receivedAt":"2009-07-31T12:35:54Z","isPatch":false,"sender":{"key":"howardsmiller@googlemail.com","avatar":"https://gravatar.com/avatar/69a7274bc5c4c66910b00e4ea6590e46e2325b53ff4807854f3ed469b49400b1?d=mp&s=160"},"body":"\nI had some unexpected behaviour doing a merge today. I wonder if anybody can\ntell me where I have gone wrong. This is the sequence...\n\n* clone a remote repo\n* created a local branch to track one of the remote branches\n* did work on the local branch and then created another 'feature' branch\nfrom that\n* time elapsed and at some point(s) I pulled from the remote but did not\nmerge the original local branch\n* finished feature, checkout local branch and merge in feature. \n\nWhat I didn't expect is that all the subsequent changes on the tracked\nremote branch got merged in too. Which I didn't want.\n\nSo the question is - is that what's supposed to happen (ie. if you do any\nmerge the tracked branch 'fast forwards' the remote) and, if so, if I want a\nbranch that stays a branch (doesn't ever merge with the remote) how would I\ndo that?\n\nThanks!\n-- \nView this message in context: http://www.nabble.com/merge-confusion-tp24755682p24755682.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"119271","messageId":"6786ed4f0907310632t2435f7d9y9151febea7844ca@mail.gmail.com","threadId":"20318","inReplyTo":"24755682.post@talk.nabble.com","subject":"Re: merge confusion","fromName":"Allen Johnson","fromEmail":"akjohnson78@gmail.com","sentAt":"2009-07-31T13:32:50Z","receivedAt":"2009-07-31T13:32:50Z","isPatch":false,"sender":{"key":"akjohnson78@gmail.com","avatar":null},"body":"I think in this case you should do a `git fetch` instead. Doing a pull\nis the same as performing a fetch and merge.\n\nWith a `fetch`, your remote branch is up-to-date while your tracking\nbranch is left untouched. You can later check the differences between\nthe two branches and merge when you're ready.\n\n$ git fetch # update remote branch heads\n$ git diff origin/branchname # show what is different between your\nlocal branch and the remote\n$ git merge origin/branchname # only when you're ready\n\nFor me, it's easier to keep my personal branches separate by using a\ntopic branch that doesn't track a remote branch. Then, optionally,\nmerge in differences from whatever remote tracking branches as needed.\n\n$ git branch -t development origin/development # tracking remote\ndevelopment branch\n$ git checkout -b mystuff development # my personal stuff\n\nNow a `git pull` won't affect `mystuff`.\n\nAllen\n\nOn Fri, Jul 31, 2009 at 8:35 AM,\nthepurpleblob<howardsmiller@googlemail.com> wrote:\n>\n> I had some unexpected behaviour doing a merge today. I wonder if anybody can\n> tell me where I have gone wrong. This is the sequence...\n>\n> * clone a remote repo\n> * created a local branch to track one of the remote branches\n> * did work on the local branch and then created another 'feature' branch\n> from that\n> * time elapsed and at some point(s) I pulled from the remote but did not\n> merge the original local branch\n> * finished feature, checkout local branch and merge in feature.\n>\n> What I didn't expect is that all the subsequent changes on the tracked\n> remote branch got merged in too. Which I didn't want.\n>\n> So the question is - is that what's supposed to happen (ie. if you do any\n> merge the tracked branch 'fast forwards' the remote) and, if so, if I want a\n> branch that stays a branch (doesn't ever merge with the remote) how would I\n> do that?\n>\n> Thanks!\n> --\n> View this message in context: http://www.nabble.com/merge-confusion-tp24755682p24755682.html\n> Sent from the git mailing list archive at Nabble.com.\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"119287","messageId":"BLU0-SMTP58E44ED78547385BC3A82BAE100@phx.gbl","threadId":"20318","inReplyTo":"24755682.post@talk.nabble.com","subject":"Re: merge confusion","fromName":"Sean Estabrooks","fromEmail":"seanlkml@sympatico.ca","sentAt":"2009-07-31T16:29:44Z","receivedAt":"2009-07-31T16:29:44Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Fri, 31 Jul 2009 06:41:32 -0700 (PDT)\nthepurpleblob <howardsmiller@googlemail.com> wrote:\n\nHoward,\n\n> I had some unexpected behaviour doing a merge today. I wonder if anybody can\n> tell me where I have gone wrong. This is the sequence...\n[...]\n\nNot sure i'm following your question, will take a crack at it though.\nI believe this is what you did:\n\n 1. cloned a remote repo\n 2. created a local branch B and committed some changes onto it\n 3. created another local branch F\n 4. committed some changes on F\n 5. pulled in additional changes from a remote repo into F\n 6. committed additional local changes on F\n 7. merged F into B\n\n> What I didn't expect is that all the subsequent changes on the tracked\n> remote branch got merged in too. Which I didn't want.\n\nWhen you merged the feature branch(F) you merged all the new commits made on\nit.  By design this includes any commits you pulled in from any remote; you\ndon't just get the subset of commits that you made locally.\n\n> So the question is - is that what's supposed to happen (ie. if you do any\n> merge the tracked branch 'fast forwards' the remote) and, if so, if I want a\n> branch that stays a branch (doesn't ever merge with the remote) how would I\n> do that?\n\nThere's nothing forcing you to merge with a remote, you just need to find a\nworkflow that accomplishes what you want.  As far as i can tell without knowing\nthe actual commands you used, it appears you explicitly asked Git to merge in\nchanges from the remote when you merged the feature branch.\n\nSo to hopefully answer your question, don't merge remote changes into your\nfeature branch if you want your feature branch to only contain local changes\nwhen you merge it with other local branches.\n\nHTH,\nSean\n"},{"id":"126128","messageId":"26093419.post@talk.nabble.com","threadId":"20318","inReplyTo":"24755682.post@talk.nabble.com","subject":"Re: merge confusion","fromName":"Tim Mazid","fromEmail":"timmazid@hotmail.com","sentAt":"2009-10-28T12:01:24Z","receivedAt":"2009-10-28T12:01:24Z","isPatch":false,"sender":{"key":"timmazid@hotmail.com","avatar":null},"body":"\n\nthepurpleblob wrote:\n> \n> I had some unexpected behaviour doing a merge today. I wonder if anybody\n> can tell me where I have gone wrong. This is the sequence...\n> \n> * clone a remote repo\n> * created a local branch to track one of the remote branches\n> * did work on the local branch and then created another 'feature' branch\n> from that\n> * time elapsed and at some point(s) I pulled from the remote but did not\n> merge the original local branch\n> * finished feature, checkout local branch and merge in feature. \n> \n> What I didn't expect is that all the subsequent changes on the tracked\n> remote branch got merged in too. Which I didn't want.\n> So the question is - is that what's supposed to happen (ie. if you do any\n> merge the tracked branch 'fast forwards' the remote) and, if so, if I want\n> a branch that stays a branch (doesn't ever merge with the remote) how\n> would I do that?\n> \n> Thanks!\n> \n\nDid you 'git pull' or 'git fetch'? 'git pull' automatically merges, where\n'git fetch' only gets the data.\nYou can just do a 'git branch branch-to-merge COMMIT' then 'git merge\nbranch-to-merge' from your feature branch. Alternatively, you could just do\na straight 'git merge COMMIT' from your feature branch. Though I'm not sure\nof the consequences of merging a commit instead of a branch.\n\nGood luck,\nTim.\n-- \nView this message in context: http://www.nabble.com/merge-confusion-tp24755682p26093419.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"126154","messageId":"81b0412b0910280843s53af2033y7e24400dca231385@mail.gmail.com","threadId":"20318","inReplyTo":"26093419.post@talk.nabble.com","subject":"Re: merge confusion","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-28T15:43:53Z","receivedAt":"2009-10-28T15:43:53Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Wed, Oct 28, 2009 at 13:01, Tim Mazid <timmazid@hotmail.com> wrote:\n> You can just do a 'git branch branch-to-merge COMMIT' then 'git merge\n> branch-to-merge' from your feature branch. Alternatively, you could just do\n> a straight 'git merge COMMIT' from your feature branch. Though I'm not sure\n> of the consequences of merging a commit instead of a branch.\n\nThe only consequence is that the merge commit message (if there will be any,\nfast-forward merges don't merge anything) will mention the SHA1 instead of\nbranch name. You can provide your own merge commit message, of course\n(while merging and afterwards).\n"}]}