{"thread":{"id":"38468","subject":"git loses commits on git pull --rebase with Dictator and Lieutenants Workflow","startedAt":"2015-01-28T19:49:02Z","lastAt":"2015-01-29T20:58:37Z","messageCount":7,"participants":["Dick","Chris Packham","Junio C Hamano","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"255378","messageId":"loom.20150128T203924-608@post.gmane.org","threadId":"38468","inReplyTo":null,"subject":"git loses commits on git pull --rebase with Dictator and Lieutenants Workflow","fromName":"Dick","fromEmail":"dick@mrns.nl","sentAt":"2015-01-28T19:49:02Z","receivedAt":"2015-01-28T19:49:02Z","isPatch":false,"sender":{"key":"dick@mrns.nl","avatar":null},"body":"Hi all,\n\nI've encountered a problem with the Dictator and Lieutenants Workflow. I've \nconfigured remote origin so it pulls from the \"blessed repository\" and \npushes to the \"developer public\" repository.\n\nWhen the \"blessed repository\" has the same branch name as the \"developer \npublic\" repository git pull seems to drop commits.\n\nI've create a test script to demonstrate, left is the blessed repository, \nright.git is the developer public and right is the developer private \nrepository.\n\nrm -rf left/ right/ right.git/\ngit init left\ncd left/\necho \"hello world\" > test.txt\ngit add test.txt \ngit commit -m .\ncd ..\ngit clone --bare left right.git\ngit clone right.git/ right\ncd right\ngit remote set-url origin ../left\ngit remote set-url origin --push ../right.git\necho \"bye world\" >> test.txt \ngit commit -a -m .\ngit push\ngit log\necho \"start: two commits, ok\"\ngit fetch\ngit rebase origin/master\ngit log\necho \"manual fetch/rebase: two commits, still ok\"\ngit pull --rebase\ngit log\necho \"pull: one commits, oops?\"\n\nAm I using git wrong or is this a git bug?\n\nThanks for having a look!\n\nDick\n"},{"id":"255409","messageId":"CAFOYHZDLPr1sJ2Agyq6tT=ahpgNp=eL_Q4c=-iDd9i_JqFNTcg@mail.gmail.com","threadId":"38468","inReplyTo":"loom.20150128T203924-608@post.gmane.org","subject":"Re: git loses commits on git pull --rebase with Dictator and Lieutenants Workflow","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2015-01-29T17:27:03Z","receivedAt":"2015-01-29T17:27:03Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"Hi,\n\nOn Thu, Jan 29, 2015 at 8:49 AM, Dick <dick@mrns.nl> wrote:\n> Hi all,\n>\n> I've encountered a problem with the Dictator and Lieutenants Workflow. I've\n> configured remote origin so it pulls from the \"blessed repository\" and\n> pushes to the \"developer public\" repository.\n>\n> When the \"blessed repository\" has the same branch name as the \"developer\n> public\" repository git pull seems to drop commits.\n>\n> I've create a test script to demonstrate, left is the blessed repository,\n> right.git is the developer public and right is the developer private\n> repository.\n>\n> rm -rf left/ right/ right.git/\n> git init left\n> cd left/\n> echo \"hello world\" > test.txt\n> git add test.txt\n> git commit -m .\n> cd ..\n> git clone --bare left right.git\n> git clone right.git/ right\n> cd right\n> git remote set-url origin ../left\n> git remote set-url origin --push ../right.git\n> echo \"bye world\" >> test.txt\n> git commit -a -m .\n> git push\n> git log\n> echo \"start: two commits, ok\"\n> git fetch\n> git rebase origin/master\n> git log\n> echo \"manual fetch/rebase: two commits, still ok\"\n> git pull --rebase\n> git log\n> echo \"pull: one commits, oops?\"\n>\n> Am I using git wrong or is this a git bug?\n>\n> Thanks for having a look!\n>\n> Dick\n\nI can confirm the behaviour that Dick is seeing with git 2.0.4\n(happens to be what I was running on my laptop). Just rebuilding\n2.3.0-rc2 now.\n\nAFAIK 'git fetch && git rebase origin/master' and 'git pull -r' in the\nscenario above should be roughly equivalent.\n\nI'll see if I can work the testcase above into an actual test script.\n"},{"id":"255411","messageId":"CAFOYHZBs=r016FE6ENOnYMs85D9XetTWtVR+faBL5Sj-91=ezg@mail.gmail.com","threadId":"38468","inReplyTo":"CAFOYHZDLPr1sJ2Agyq6tT=ahpgNp=eL_Q4c=-iDd9i_JqFNTcg@mail.gmail.com","subject":"Re: git loses commits on git pull --rebase with Dictator and Lieutenants Workflow","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2015-01-29T18:08:29Z","receivedAt":"2015-01-29T18:08:29Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On Fri, Jan 30, 2015 at 6:27 AM, Chris Packham <judge.packham@gmail.com> wrote:\n> Hi,\n>\n> On Thu, Jan 29, 2015 at 8:49 AM, Dick <dick@mrns.nl> wrote:\n>> Hi all,\n>>\n>> I've encountered a problem with the Dictator and Lieutenants Workflow. I've\n>> configured remote origin so it pulls from the \"blessed repository\" and\n>> pushes to the \"developer public\" repository.\n>>\n>> When the \"blessed repository\" has the same branch name as the \"developer\n>> public\" repository git pull seems to drop commits.\n>>\n>> I've create a test script to demonstrate, left is the blessed repository,\n>> right.git is the developer public and right is the developer private\n>> repository.\n>>\n>> rm -rf left/ right/ right.git/\n>> git init left\n>> cd left/\n>> echo \"hello world\" > test.txt\n>> git add test.txt\n>> git commit -m .\n>> cd ..\n>> git clone --bare left right.git\n>> git clone right.git/ right\n>> cd right\n>> git remote set-url origin ../left\n>> git remote set-url origin --push ../right.git\n>> echo \"bye world\" >> test.txt\n>> git commit -a -m .\n>> git push\n>> git log\n>> echo \"start: two commits, ok\"\n>> git fetch\n>> git rebase origin/master\n>> git log\n>> echo \"manual fetch/rebase: two commits, still ok\"\n>> git pull --rebase\n>> git log\n>> echo \"pull: one commits, oops?\"\n>>\n>> Am I using git wrong or is this a git bug?\n>>\n>> Thanks for having a look!\n>>\n>> Dick\n>\n> I can confirm the behaviour that Dick is seeing with git 2.0.4\n> (happens to be what I was running on my laptop). Just rebuilding\n> 2.3.0-rc2 now.\n\nAlso happens on 2.3.0-rc2\n\n>\n> AFAIK 'git fetch && git rebase origin/master' and 'git pull -r' in the\n> scenario above should be roughly equivalent.\n>\n> I'll see if I can work the testcase above into an actual test script.\n"},{"id":"255413","messageId":"xmqqlhkle64d.fsf@gitster.dls.corp.google.com","threadId":"38468","inReplyTo":"loom.20150128T203924-608@post.gmane.org","subject":"Re: git loses commits on git pull --rebase with Dictator and Lieutenants Workflow","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-29T19:31:14Z","receivedAt":"2015-01-29T19:31:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dick <dick@mrns.nl> writes:\n\n> rm -rf left/ right/ right.git/\n> git init left\n> cd left/\n> echo \"hello world\" > test.txt\n> git add test.txt \n> git commit -m .\n> cd ..\n> git clone --bare left right.git\n> git clone right.git/ right\n> cd right\n> git remote set-url origin ../left\n> git remote set-url origin --push ../right.git\n\nThis is not using \"origin\" and set-url correctly.  Even though you\ncan use physically different URLs for fetching from and pushing\ninto, the named repository 'origin' is still conceptually the same\nrepository.  You use this mechanism when you want to fetch over the\npublic git:// protocol (which is lighter-weight) while pushing into\nthe same repository over ssh:// protocol (which may be heavier and\nrequires authentication).  The important part of the equation is\nthat the data should go to and come from the same place.  What you\npushed to 'origin', if you fetch from 'origin' again, should come\nback to you.\n\nAnd that is not what your two calls to set-url are doing.\n\nIn a triangular workflow to fetch from somewhere while pushing into\nsomewhere else, you are using _two_ different repositories: your\nupstream's repository you fetch from, and your own repository you\npush to publish your result.  So you would use _two_ remotes, not a\nsingle 'origin'.\n\t\nThe 'right' person, who follows the 'left' developer who publishes\nthe more authoritative work in 'left.git' for you and others to\nfetch from, and publishes his work to 'right.git' to ask 'left' to\npull, would do something like:\n\n\tgit init --bare right.git\n\tgit clone left right\n\tcd right\n        git remote add mine ../right.git\n        git config remote.pushDefault mine\n        git push --all;# to publish to ../right.git\n\nto set things up.  Then\n\n\tedit && git commit && git other-commands && ...\n\tgit push ;# updates ../right.git\n\nto publish his work.  Updating from 'left' would go like this:\n\n\t# pretend 'left' did something\n\t( cd ../left && git commit --allow-empty -m empty )\n\n\tgit pull ;# or 'git pull --rebase'\n"},{"id":"255414","messageId":"loom.20150129T205443-493@post.gmane.org","threadId":"38468","inReplyTo":"xmqqlhkle64d.fsf@gitster.dls.corp.google.com","subject":"Re: git loses commits on git pull --rebase with Dictator and Lieutenants Workflow","fromName":"Dick","fromEmail":"dick@mrns.nl","sentAt":"2015-01-29T19:59:02Z","receivedAt":"2015-01-29T19:59:02Z","isPatch":false,"sender":{"key":"dick@mrns.nl","avatar":null},"body":"Thanks Junio! I should use git config remote.pushDefault thanks for pointing \nme in the right direction.\n\nI guess the git remote set-url --push command should contain some warning \nabout this.\n\ngr\nDick\n"},{"id":"255415","messageId":"xmqqegqde3ku.fsf_-_@gitster.dls.corp.google.com","threadId":"38468","inReplyTo":"loom.20150129T205443-493@post.gmane.org","subject":"Re* git loses commits on git pull --rebase with Dictator and Lieutenants Workflow","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-29T20:26:09Z","receivedAt":"2015-01-29T20:26:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dick <dick@mrns.nl> writes:\n\n> I guess the git remote set-url --push command should contain some warning \n> about this.\n\nPerhaps something like this would be good enough for a starter.\n\n-- >8 --\nSubject: Documentation/git-remote.txt: stress that set-url is not for triangular\n\nIt seems to be a common mistake to try using a single remote\n(e.g. 'origin') to fetch from one place (i.e. upstream) while\npushing to another (i.e. your publishing point).  That will never\nwork satisfactory.  Think about what refs/remotes/origin/* would\nmean in such a world---it fundamentally cannot reflect the reality.\nIf it follows the state of your upstream, it cannot match what you\nhave published, and vice versa.\n\nSome low-quality websites may be spreading misinformation.  Let's\ncounter them by adding a few words to our documentation.\n\n - The description was referring to <oldurl> and <newurl>, but never\n   mentioned <name> argument you give from the command line.  By\n   mentioning \"remote <name>\", stress the fact that it is configuring\n   a single remote.\n\n - Add a reminder that explicitly states that this is about a single\n   remote, which the triangular workflow is not about.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-remote.txt | 20 ++++++++++++++------\n 1 file changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex cb103c8..a77607b 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -130,17 +130,25 @@ branches, adds to that list.\n \n 'set-url'::\n \n-Changes URL remote points to. Sets first URL remote points to matching\n+Changes URLs for the remote. Sets first URL for remote <name> that matches\n regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If\n-<oldurl> doesn't match any URL, error occurs and nothing is changed.\n+<oldurl> doesn't match any URL, an error occurs and nothing is changed.\n +\n With '--push', push URLs are manipulated instead of fetch URLs.\n +\n-With '--add', instead of changing some URL, new URL is added.\n+With '--add', instead of changing existing URLs, new URL is added.\n +\n-With '--delete', instead of changing some URL, all URLs matching\n-regex <url> are deleted. Trying to delete all non-push URLs is an\n-error.\n+With '--delete', instead of changing existing URLs, all URLs matching\n+regex <url> are deleted for remote <name>.  Trying to delete all\n+non-push URLs is an error.\n++\n+Note that the push URL and the fetch URL, even though they can\n+be set differently, must still refer to the same place.  What you\n+pushed to the push URL should be what you would see if you\n+immediately fetched from the fetch URL.  If you are trying to\n+fetch from one place (e.g. your upstream) and push to another (e.g.\n+your publishing repository), use two separate remotes.\n+\n \n 'show'::\n \n"},{"id":"255417","messageId":"CAPig+cTvBs3Dq3EWEJ6wYEnMJx5CRLxtDUaLZgExOUT9gtw5_A@mail.gmail.com","threadId":"38468","inReplyTo":"xmqqegqde3ku.fsf_-_@gitster.dls.corp.google.com","subject":"Re: Re* git loses commits on git pull --rebase with Dictator and Lieutenants Workflow","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-01-29T20:58:37Z","receivedAt":"2015-01-29T20:58:37Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Jan 29, 2015 at 3:26 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Subject: Documentation/git-remote.txt: stress that set-url is not for triangular\n>\n> It seems to be a common mistake to try using a single remote\n> (e.g. 'origin') to fetch from one place (i.e. upstream) while\n> pushing to another (i.e. your publishing point).  That will never\n> work satisfactory.  Think about what refs/remotes/origin/* would\n\ns/satisfactory/satisfactorily/\n\n> mean in such a world---it fundamentally cannot reflect the reality.\n> If it follows the state of your upstream, it cannot match what you\n> have published, and vice versa.\n>\n> Some low-quality websites may be spreading misinformation.  Let's\n> counter them by adding a few words to our documentation.\n>\n>  - The description was referring to <oldurl> and <newurl>, but never\n>    mentioned <name> argument you give from the command line.  By\n>    mentioning \"remote <name>\", stress the fact that it is configuring\n>    a single remote.\n>\n>  - Add a reminder that explicitly states that this is about a single\n>    remote, which the triangular workflow is not about.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n"}]}