{"thread":{"id":"19331","subject":"switching upstream tips","startedAt":"2009-05-13T06:42:25Z","lastAt":"2009-05-13T09:05:19Z","messageCount":12,"participants":["Ittay Dror","Alex Riesen","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"113726","messageId":"4A0A6BD1.7050907@gmail.com","threadId":"19331","inReplyTo":null,"subject":"switching upstream tips","fromName":"Ittay Dror","fromEmail":"ittay.dror@gmail.com","sentAt":"2009-05-13T06:42:25Z","receivedAt":"2009-05-13T06:42:25Z","isPatch":false,"sender":{"key":"ittay.dror@gmail.com","avatar":"https://gravatar.com/avatar/0dc47ece3354a295768075bb5afa328d49cda722c9f3100029ada80ee4561e22?d=mp&s=160"},"body":"Hi,\n\n\nI'm working on a repository in github that is forked from another \nrepository. I've committed several times and pulled (merged) from the \nupstream a few times (so the committs are interleaved). The upstream \nrepository is a clone of an SVN repository (in apache). The project has \nswitched svn repositories (moved from incubation to top level project) \nand so created a new repository in github.\n\n\nNow I want to start working with the new upstream repository. My problem \nis that because of the changes in the backing SVN, the objects are \ncompletely new, so when i try 'git pull new-upstream master', I get a \nlot of add/add conflicts. Most of the conflicts show the whole file has \nchanged while actually just a few lines differ. So I'm having trouble \nmaking sense of the mess.\n\n\nWhat I'm trying to figure out is how to do the following:\n\n* Reorder my history so that my commits are on top of the tip of the old \nupstream repository.\n\n* Change the upstream repository reference so it points to the new \nrepository\n\n* Apply my commits on top of the new upstream repository\n\n\nOf course any other alternative which will allow me to continue to work \nwith the new upstream is also welcome.\n\n\nThank you,\n\nIttay\n"},{"id":"113730","messageId":"81b0412b0905130019x114d53d1v86833217bff613bc@mail.gmail.com","threadId":"19331","inReplyTo":"4A0A6BD1.7050907@gmail.com","subject":"Re: switching upstream tips","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-05-13T07:19:57Z","receivedAt":"2009-05-13T07:19:57Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n> I'm working on a repository in github that is forked from another\n> repository. I've committed several times and pulled (merged) from the\n> upstream a few times (so the committs are interleaved). The upstream\n> repository is a clone of an SVN repository (in apache). The project has\n> switched svn repositories (moved from incubation to top level project) and\n> so created a new repository in github.\n\nThat's evil.\n\n> * Reorder my history so that my commits are on top of the tip of the old\n> upstream repository.\n\nLook at \"git rebase -i\" (interactive rebase)\n\n> * Change the upstream repository reference so it points to the new\n> repository\n\nJust edit your .git/config and re-fetch.\n\n> * Apply my commits on top of the new upstream repository\n\nYou can try to cherry-pick your commits (git cherry-pick).\nMaybe rename detection will be enough to apply your changes\nas is. But as far as I understand, the path names in the new\nupstream are now all different (moved a level up?).\nYou can save your commits in a mbox:\n\n   git format-patch -o mbox old-upstream..your-last-commit\n\nEdit the paths in the mbox and try to apply the result:\n\n   git am -3 result.mbox\n\nOr, you can use git filter-branch to modify the old history as if it\nwas always operating on the directory structure of the new\nupsteam (assuming it is possible, of course). See manpage\nof git filter-branch, there is an example (look for \"move the whole\ntree into a subdirectory\").\n"},{"id":"113731","messageId":"4A0A77D8.3030000@gmail.com","threadId":"19331","inReplyTo":"81b0412b0905130019x114d53d1v86833217bff613bc@mail.gmail.com","subject":"Re: switching upstream tips","fromName":"Ittay Dror","fromEmail":"ittay.dror@gmail.com","sentAt":"2009-05-13T07:33:44Z","receivedAt":"2009-05-13T07:33:44Z","isPatch":false,"sender":{"key":"ittay.dror@gmail.com","avatar":"https://gravatar.com/avatar/0dc47ece3354a295768075bb5afa328d49cda722c9f3100029ada80ee4561e22?d=mp&s=160"},"body":"\n\nAlex Riesen wrote:\n\n> 2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n>   \n>> I'm working on a repository in github that is forked from another\n>> repository. I've committed several times and pulled (merged) from the\n>> upstream a few times (so the committs are interleaved). The upstream\n>> repository is a clone of an SVN repository (in apache). The project has\n>> switched svn repositories (moved from incubation to top level project) and\n>> so created a new repository in github.\n>>     \n>\n> That's evil.\n>\n>   \n>> * Reorder my history so that my commits are on top of the tip of the old\n>> upstream repository.\n>>     \n>\n> Look at \"git rebase -i\" (interactive rebase)\n>   \nwell, i was hoping for something more automatic. git rebase will list \nall commits without author, so i'll have to manually figure which of \nthem is mine from the commend and reorder\n>   \n>> * Change the upstream repository reference so it points to the new\n>> repository\n>>     \n>\n> Just edit your .git/config and re-fetch.\n>   \nbut then git suddenly sees a bunch of new objects (because of the svn \nchanges) and i get a lot of conflicts. note that it is not the directory \nstructure that changed, just the svn repository which is included in the \ncommit comment (by git-svn) and so changes the commit sha1.\n>   \n>> * Apply my commits on top of the new upstream repository\n>>     \n>\n> You can try to cherry-pick your commits (git cherry-pick).\n> Maybe rename detection will be enough to apply your changes\n> as is. But as far as I understand, the path names in the new\n> upstream are now all different (moved a level up?).\n> You can save your commits in a mbox:\n>\n>    git format-patch -o mbox old-upstream..your-last-commit\n>\n> Edit the paths in the mbox and try to apply the result:\n>\n>    git am -3 result.mbox\n>\n> Or, you can use git filter-branch to modify the old history as if it\n> was always operating on the directory structure of the new\n> upsteam (assuming it is possible, of course). See manpage\n> of git filter-branch, there is an example (look for \"move the whole\n> tree into a subdirectory\").\n>   \n"},{"id":"113733","messageId":"81b0412b0905130041t327ef5f2m3b6d1dfac51fc1b1@mail.gmail.com","threadId":"19331","inReplyTo":"4A0A777E.7080506@gmail.com","subject":"Re: switching upstream tips","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-05-13T07:41:40Z","receivedAt":"2009-05-13T07:41:40Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n>> Alex Riesen wrote:\n>>> * Reorder my history so that my commits are on top of the tip of the old\n>>> upstream repository.\n>>\n>> Look at \"git rebase -i\" (interactive rebase)\n>\n> well, i was hoping for something more automatic. git rebase will list all\n> commits without author, so i'll have to manually figure which of them is\n> mine from the commend and reorder\n\ngit rebase will list only commits not on upstream (simplified).\nHas nothing to do with author being absent.\n\n>>> * Change the upstream repository reference so it points to the new\n>>> repository\n>>\n>> Just edit your .git/config and re-fetch.\n>\n> but then git suddenly sees a bunch of new objects (because of the svn\n> changes) and i get a lot of conflicts.\n\n\"git fetch\" and \"git remote update\" do not produce conflicts. You cannot\nget them unless you also do a merge (like when you do \"git merge\" or\n\"git pull\").\n\n> note that it is not the directory structure that changed, just the svn\n> repository which is included in the commit comment (by git-svn) and\n> so changes the commit sha1.\n\nOk, that simplifies everything. Just cherry-pick (see \"git cherry-pick\")\nyour commits on new upstream. You might find it easiest if you cherry-pick\nthem on commits in new upstream which correspond the old-upstream\nexactly.\n"},{"id":"113734","messageId":"4A0A7BA1.4030500@gmail.com","threadId":"19331","inReplyTo":"81b0412b0905130041t327ef5f2m3b6d1dfac51fc1b1@mail.gmail.com","subject":"Re: switching upstream tips","fromName":"Ittay Dror","fromEmail":"ittay.dror@gmail.com","sentAt":"2009-05-13T07:49:53Z","receivedAt":"2009-05-13T07:49:53Z","isPatch":false,"sender":{"key":"ittay.dror@gmail.com","avatar":"https://gravatar.com/avatar/0dc47ece3354a295768075bb5afa328d49cda722c9f3100029ada80ee4561e22?d=mp&s=160"},"body":"\n\nAlex Riesen wrote:\n\n> 2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n>   \n>>> Alex Riesen wrote:\n>>>       \n>>>> * Reorder my history so that my commits are on top of the tip of the old\n>>>> upstream repository.\n>>>>         \n>>> Look at \"git rebase -i\" (interactive rebase)\n>>>       \n>> well, i was hoping for something more automatic. git rebase will list all\n>> commits without author, so i'll have to manually figure which of them is\n>> mine from the commend and reorder\n>>     \n>\n> git rebase will list only commits not on upstream (simplified).\n> Has nothing to do with author being absent.\n>   \ntried git rebase, this is what i get:\n > git rebase -i upstream master\nfatal: Needed a single revision\nInvalid base\n\n>   \n>>>> * Change the upstream repository reference so it points to the new\n>>>> repository\n>>>>         \n>>> Just edit your .git/config and re-fetch.\n>>>       \n>> but then git suddenly sees a bunch of new objects (because of the svn\n>> changes) and i get a lot of conflicts.\n>>     \n>\n> \"git fetch\" and \"git remote update\" do not produce conflicts. You cannot\n> get them unless you also do a merge (like when you do \"git merge\" or\n> \"git pull\").\n>\n>   \n>> note that it is not the directory structure that changed, just the svn\n>> repository which is included in the commit comment (by git-svn) and\n>> so changes the commit sha1.\n>>     \n>\n> Ok, that simplifies everything. Just cherry-pick (see \"git cherry-pick\")\n> your commits on new upstream. You might find it easiest if you cherry-pick\n> them on commits in new upstream which correspond the old-upstream\n> exactly.\n>   \ncan you explain a bit more how to work with git cherry-pick? if i \nunderstand correctly, i need to write down my commits, switch to the new \nupstream tip ('git checkout upstream master'?) and then call git \ncherry-pick for each of my commits.\n\n\nittay\n"},{"id":"113735","messageId":"4A0A7D5E.1010909@viscovery.net","threadId":"19331","inReplyTo":"4A0A7BA1.4030500@gmail.com","subject":"Re: switching upstream tips","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-05-13T07:57:18Z","receivedAt":"2009-05-13T07:57:18Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Ittay Dror schrieb:\n> Alex Riesen wrote:\n>> 2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n>>>> Alex Riesen wrote:\n>>>>> * Reorder my history so that my commits are on top of the tip of\n>>>>> the old\n>>>>> upstream repository.\n>>>>>         \n>>>> Look at \"git rebase -i\" (interactive rebase)\n>>>>       \n>>> well, i was hoping for something more automatic. git rebase will list\n>>> all\n>>> commits without author, so i'll have to manually figure which of them is\n>>> mine from the commend and reorder\n>>>     \n>>\n>> git rebase will list only commits not on upstream (simplified).\n>> Has nothing to do with author being absent.\n>>   \n> tried git rebase, this is what i get:\n>> git rebase -i upstream master\n> fatal: Needed a single revision\n> Invalid base\n\nI guess it should have been\n\n   git rebase -i --onto new-upstream old-upstream master\n\nThat is, you take commits old-upstream..master and transplant them onto\nnew-upstream.\n\n-- Hannes\n"},{"id":"113737","messageId":"4A0A7FBA.1010606@gmail.com","threadId":"19331","inReplyTo":"4A0A7D5E.1010909@viscovery.net","subject":"Re: switching upstream tips","fromName":"Ittay Dror","fromEmail":"ittay.dror@gmail.com","sentAt":"2009-05-13T08:07:22Z","receivedAt":"2009-05-13T08:07:22Z","isPatch":false,"sender":{"key":"ittay.dror@gmail.com","avatar":"https://gravatar.com/avatar/0dc47ece3354a295768075bb5afa328d49cda722c9f3100029ada80ee4561e22?d=mp&s=160"},"body":"\n\nJohannes Sixt wrote:\n\n> Ittay Dror schrieb:\n>   \n>> Alex Riesen wrote:\n>>     \n>>> 2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n>>>       \n>>>>> Alex Riesen wrote:\n>>>>>           \n>>>>>> * Reorder my history so that my commits are on top of the tip of\n>>>>>> the old\n>>>>>> upstream repository.\n>>>>>>         \n>>>>>>             \n>>>>> Look at \"git rebase -i\" (interactive rebase)\n>>>>>       \n>>>>>           \n>>>> well, i was hoping for something more automatic. git rebase will list\n>>>> all\n>>>> commits without author, so i'll have to manually figure which of them is\n>>>> mine from the commend and reorder\n>>>>     \n>>>>         \n>>> git rebase will list only commits not on upstream (simplified).\n>>> Has nothing to do with author being absent.\n>>>   \n>>>       \n>> tried git rebase, this is what i get:\n>>     \n>>> git rebase -i upstream master\n>>>       \n>> fatal: Needed a single revision\n>> Invalid base\n>>     \n>\n> I guess it should have been\n>\n>    git rebase -i --onto new-upstream old-upstream master\n>\n> That is, you take commits old-upstream..master and transplant them onto\n> new-upstream.\n>   \nsame thing:\n > git rebase -i --onto upstream old-upstream master\nfatal: Needed a single revision\nDoes not point to a valid commit: upstream\n\n> -- Hannes\n>\n>   \n"},{"id":"113738","messageId":"81b0412b0905130115v78b5065bjdeb3f349072eed4c@mail.gmail.com","threadId":"19331","inReplyTo":"4A0A7BA1.4030500@gmail.com","subject":"Re: switching upstream tips","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-05-13T08:15:29Z","receivedAt":"2009-05-13T08:15:29Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n>\n> tried git rebase, this is what i get:\n> git rebase -i upstream master\n> fatal: Needed a single revision\n> Invalid base\n\n$ git checkout my-old-master-based-on-old-upstream\n$ git rebase -i old-upstream\n\n>> Ok, that simplifies everything. Just cherry-pick (see \"git cherry-pick\")\n>> your commits on new upstream. You might find it easiest if you cherry-pick\n>> them on commits in new upstream which correspond the old-upstream\n>> exactly.\n>\n> can you explain a bit more how to work with git cherry-pick? if i understand\n> correctly, i need to write down my commits, switch to the new upstream tip\n> ('git checkout upstream master'?) and then call git cherry-pick for each of\n> my commits.\n\n$ gitk old-upstream-with-my-changes-on-top &\n$ git checkout -b my-new-master-on-top-of-new-upstream  new-upstream\n...select a commit in gitk...\n$ git cherry-pick <paste-the-selected-commit-here> # hit Enter\n\nrepeat until you run out of commits you want to have on top of the new upstream.\n"},{"id":"113739","messageId":"4A0A81DE.9070506@viscovery.net","threadId":"19331","inReplyTo":"4A0A7FBA.1010606@gmail.com","subject":"Re: switching upstream tips","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-05-13T08:16:30Z","receivedAt":"2009-05-13T08:16:30Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Ittay Dror schrieb:\n> same thing:\n>> git rebase -i --onto upstream old-upstream master\n> fatal: Needed a single revision\n> Does not point to a valid commit: upstream\n\nI guess you don't have a branch with the name \"upstream\". Use the name (or\nSHA1) that designates your upstream.\n\n-- Hannes\n"},{"id":"113740","messageId":"81b0412b0905130116l1ec0eb56p67003bacfa19c3d6@mail.gmail.com","threadId":"19331","inReplyTo":"4A0A7FBA.1010606@gmail.com","subject":"Re: switching upstream tips","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-05-13T08:16:31Z","receivedAt":"2009-05-13T08:16:31Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n> Johannes Sixt wrote:\n>> I guess it should have been\n>>\n>>   git rebase -i --onto new-upstream old-upstream master\n>>\n>> That is, you take commits old-upstream..master and transplant them onto\n>> new-upstream.\n>>\n>\n> same thing:\n>> git rebase -i --onto upstream old-upstream master\n> fatal: Needed a single revision\n> Does not point to a valid commit: upstream\n\nWell, don't put random characters where your branch names should be.\n"},{"id":"113744","messageId":"4A0A858C.2070808@gmail.com","threadId":"19331","inReplyTo":"81b0412b0905130115v78b5065bjdeb3f349072eed4c@mail.gmail.com","subject":"Re: switching upstream tips","fromName":"Ittay Dror","fromEmail":"ittay.dror@gmail.com","sentAt":"2009-05-13T08:32:12Z","receivedAt":"2009-05-13T08:32:12Z","isPatch":false,"sender":{"key":"ittay.dror@gmail.com","avatar":"https://gravatar.com/avatar/0dc47ece3354a295768075bb5afa328d49cda722c9f3100029ada80ee4561e22?d=mp&s=160"},"body":"\n\nAlex Riesen wrote:\n> 2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n>   \n>> tried git rebase, this is what i get:\n>> git rebase -i upstream master\n>> fatal: Needed a single revision\n>> Invalid base\n>>     \n>\n> $ git checkout my-old-master-based-on-old-upstream\n> $ git rebase -i old-upstream\n>   \nso i need to create an 'old-upstream' branch first, that is based on the \ntip of the old-upstream remote, right? how? (thanks for the patience)\n>   \n>>> Ok, that simplifies everything. Just cherry-pick (see \"git cherry-pick\")\n>>> your commits on new upstream. You might find it easiest if you cherry-pick\n>>> them on commits in new upstream which correspond the old-upstream\n>>> exactly.\n>>>       \n>> can you explain a bit more how to work with git cherry-pick? if i understand\n>> correctly, i need to write down my commits, switch to the new upstream tip\n>> ('git checkout upstream master'?) and then call git cherry-pick for each of\n>> my commits.\n>>     \n>\n> $ gitk old-upstream-with-my-changes-on-top &\n> $ git checkout -b my-new-master-on-top-of-new-upstream  new-upstream\n> ...select a commit in gitk...\n> $ git cherry-pick <paste-the-selected-commit-here> # hit Enter\n>\n> repeat until you run out of commits you want to have on top of the new upstream.\n>   \n"},{"id":"113748","messageId":"81b0412b0905130205u68237834o9172685974cbac4f@mail.gmail.com","threadId":"19331","inReplyTo":"4A0A858C.2070808@gmail.com","subject":"Re: switching upstream tips","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-05-13T09:05:19Z","receivedAt":"2009-05-13T09:05:19Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n> Alex Riesen wrote:\n>> 2009/5/13 Ittay Dror <ittay.dror@gmail.com>:\n>>>\n>>> tried git rebase, this is what i get:\n>>> git rebase -i upstream master\n>>> fatal: Needed a single revision\n>>> Invalid base\n>>>\n>>\n>> $ git checkout my-old-master-based-on-old-upstream\n>> $ git rebase -i old-upstream\n>>\n>\n> so i need to create an 'old-upstream' branch first, that is based on the tip\n> of the old-upstream remote, right? how?\n\nno. Just use the remote reference. Should be something like\norigin/master. It is the reference to the commit where to put your\ncommits on. You can use the SHA1 there, if you wish.\nAll the rebasing happens on and to that branch of yours\n(my-old-master-based-on-old-upstream in the example above)\n\n> (thanks for the patience)\n\nThis patience is just about to end. Ever looked at the man pages?\n\"git help git\" can be a good start.\n"}]}