{"thread":{"id":"10867","subject":"How to change a submodue as a subdirectory?","startedAt":"2007-11-14T14:37:57Z","lastAt":"2007-11-15T16:41:05Z","messageCount":7,"participants":["Ping Yin","Alex Riesen","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"59851","messageId":"46dff0320711140637s51e1368fv3f632b6f04d093d5@mail.gmail.com","threadId":"10867","inReplyTo":null,"subject":"How to change a submodue as a subdirectory?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-14T14:37:57Z","receivedAt":"2007-11-14T14:37:57Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"I have a super project superA, and a submodue subB. Now i decide to\nswitch subB from submodule to sub directory. Any good way to do that\nand not losing any history?\n\n-- \nPing Yin\n"},{"id":"59872","messageId":"20071114202651.GC3973@steel.home","threadId":"10867","inReplyTo":"46dff0320711140637s51e1368fv3f632b6f04d093d5@mail.gmail.com","subject":"Re: How to change a submodue as a subdirectory?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-11-14T20:26:51Z","receivedAt":"2007-11-14T20:26:51Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Ping Yin, Wed, Nov 14, 2007 15:37:57 +0100:\n> I have a super project superA, and a submodue subB. Now i decide to\n> switch subB from submodule to sub directory. Any good way to do that\n> and not losing any history?\n\n$ mv subB sub\n$ git add sub\n$ git update-index --force-remove subB\n$ git commit\n\nWhich history were you afraid of losing?\n"},{"id":"59924","messageId":"46dff0320711142136r2c70d698vd380c02188f95507@mail.gmail.com","threadId":"10867","inReplyTo":"20071114202651.GC3973@steel.home","subject":"Re: How to change a submodue as a subdirectory?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-15T05:36:16Z","receivedAt":"2007-11-15T05:36:16Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Nov 15, 2007 4:26 AM, Alex Riesen <raa.lkml@gmail.com> wrote:\n> Ping Yin, Wed, Nov 14, 2007 15:37:57 +0100:\n> > I have a super project superA, and a submodue subB. Now i decide to\n> > switch subB from submodule to sub directory. Any good way to do that\n> > and not losing any history?\n>\n> $ mv subB sub\n> $ git add sub\n> $ git update-index --force-remove subB\n> $ git commit\n>\n> Which history were you afraid of losing?\n>\nI want to keep the history of the submodule\n\n\n\n-- \nPing Yin\n"},{"id":"59927","messageId":"Pine.LNX.4.64.0711150614380.4362@racer.site","threadId":"10867","inReplyTo":"46dff0320711142136r2c70d698vd380c02188f95507@mail.gmail.com","subject":"Re: How to change a submodue as a subdirectory?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-15T06:16:12Z","receivedAt":"2007-11-15T06:16:12Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 15 Nov 2007, Ping Yin wrote:\n\n> On Nov 15, 2007 4:26 AM, Alex Riesen <raa.lkml@gmail.com> wrote:\n> > Ping Yin, Wed, Nov 14, 2007 15:37:57 +0100:\n> > > I have a super project superA, and a submodue subB. Now i decide to\n> > > switch subB from submodule to sub directory. Any good way to do that\n> > > and not losing any history?\n> >\n> > $ mv subB sub\n> > $ git add sub\n> > $ git update-index --force-remove subB\n> > $ git commit\n> >\n> > Which history were you afraid of losing?\n> >\n> I want to keep the history of the submodule\n\nProvided you do not kill the repository of the submodule (you have some \npublic repo for that, right?) you will not lose anything, since the \nhistory of the superproject has pointers to the submodule.\n\nBut I guess that you want something different... You probably want to \nrewrite history as if the submodule had not been a submodule at all, \nright?\n\nCiao,\nDscho\n"},{"id":"59945","messageId":"46dff0320711150014x4a35975eqc53ef1fce7d40b18@mail.gmail.com","threadId":"10867","inReplyTo":"Pine.LNX.4.64.0711150614380.4362@racer.site","subject":"Re: How to change a submodue as a subdirectory?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-15T08:14:19Z","receivedAt":"2007-11-15T08:14:19Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Nov 15, 2007 2:16 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Provided you do not kill the repository of the submodule (you have some\n> public repo for that, right?) you will not lose anything, since the\n> history of the superproject has pointers to the submodule.\n>\n> But I guess that you want something different... You probably want to\n> rewrite history as if the submodule had not been a submodule at all,\n> right?\nYeah, this actually what i want. Now i find a way:\n1. move submodule subB outside\n    mv subB /newpath/to/subB\n    git-commit subB\n2. git-filter-branch to rename all files in subA repository to subB\ndirectory (say subB/subB).\n\n       cd newpath/to/subB &&\n       git filter-branch --index-filter \\\n               'git ls-files -s | sed \"s-\\t-&subB/-\" |\n                       GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n                               git update-index --index-info &&\n                mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n3. in directory of super project superA, git-fetch repository subB to\nbranch subB\n   cd path/to/superA && git-fetch /newpath/to/subB master:subB\n4. git-cherry-pick each commit  (except the root commit) of branch\nsubB to the super project superA\n    git-cherry HEAD subB | awk '{print $2}' | sed -n '2,$ p' | while\nread name; do git cherry-pick $name; done\n>\n> Ciao,\n> Dscho\n>\n>\n\n\n\n-- \nPing Yin\n"},{"id":"59976","messageId":"Pine.LNX.4.64.0711151322590.16728@wbgn129.biozentrum.uni-wuerzburg.de","threadId":"10867","inReplyTo":"46dff0320711150014x4a35975eqc53ef1fce7d40b18@mail.gmail.com","subject":"Re: How to change a submodue as a subdirectory?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-15T12:28:55Z","receivedAt":"2007-11-15T12:28:55Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 15 Nov 2007, Ping Yin wrote:\n\n> On Nov 15, 2007 2:16 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > Provided you do not kill the repository of the submodule (you have some\n> > public repo for that, right?) you will not lose anything, since the\n> > history of the superproject has pointers to the submodule.\n> >\n> > But I guess that you want something different... You probably want to\n> > rewrite history as if the submodule had not been a submodule at all,\n> > right?\n>\n> Yeah, this actually what i want. Now i find a way:\n\nIf this works for you, I am all the more happy for you.  I thought that \nyou wanted to be able to go to a certain revision and get the same working \ndirectory/directories.  (But that is not what you get...)\n\n> 1. move submodule subB outside\n>     mv subB /newpath/to/subB\n>     git-commit subB\n\nStrictly speaking, you do not have to move it outside.\n\n> 2. git-filter-branch to rename all files in subA repository to subB\n> directory (say subB/subB).\n> \n>        cd newpath/to/subB &&\n>        git filter-branch --index-filter \\\n>                'git ls-files -s | sed \"s-\\t-&subB/-\" |\n>                        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n>                                git update-index --index-info &&\n>                 mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n\nNo need to play games with GIT_INDEX_FILE, as far as I can tell.\n\n> 3. in directory of super project superA, git-fetch repository subB to\n> branch subB\n>    cd path/to/superA && git-fetch /newpath/to/subB master:subB\n\nIf you plan to do away with subB, you do not need to specify it... Just \nuse FETCH_HEAD, directly after the fetch.\n\n> 4. git-cherry-pick each commit  (except the root commit) of branch\n> subB to the super project superA\n>     git-cherry HEAD subB | awk '{print $2}' | sed -n '2,$ p' | while\n> read name; do git cherry-pick $name; done\n\nThe git-cherry call is not really necessary, right?  The two repos have no \ncommon history (not even common patches).\n\nBesides, I think that what you did is just a complicated way of doing a \nrebase.\n\nBut be aware that checking out older versions of the superproject will \nstill have the submodule!\n\nCiao,\nDscho\n"},{"id":"60000","messageId":"46dff0320711150841g1ec2a238r7fe5650e8cfaee03@mail.gmail.com","threadId":"10867","inReplyTo":"Pine.LNX.4.64.0711151322590.16728@wbgn129.biozentrum.uni-wuerzburg.de","subject":"Re: How to change a submodue as a subdirectory?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-15T16:41:05Z","receivedAt":"2007-11-15T16:41:05Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Nov 15, 2007 8:28 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n\n>\n> > 1. move submodule subB outside\n> >     mv subB /newpath/to/subB\n> >     git-commit subB\n>\n> Strictly speaking, you do not have to move it outside.\nHmm, you're right. I can just just remove it after fetch subB as a\nbranch of superA.\n>\n> > 2. git-filter-branch to rename all files in subA repository to subB\n> > directory (say subB/subB).\n> >\n> >        cd newpath/to/subB &&\n> >        git filter-branch --index-filter \\\n> >                'git ls-files -s | sed \"s-\\t-&subB/-\" |\n> >                        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n> >                                git update-index --index-info &&\n> >                 mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n>\n> No need to play games with GIT_INDEX_FILE, as far as I can tell.\nI just follow the example of git-filter-branch manual page. If not\nusing GIT_INDEX_FILE.new, the GIT_INDEX_FILE will be read and wirtten\nat the same time since it is read and writtern at the same in a pipe.\nWill this be ok?\n>\n> > 3. in directory of super project superA, git-fetch repository subB to\n> > branch subB\n> >    cd path/to/superA && git-fetch /newpath/to/subB master:subB\n>\n> If you plan to do away with subB, you do not need to specify it... Just\n> use FETCH_HEAD, directly after the fetch.\nHmm, using FETCH_HEAD is really better.\n\n> The git-cherry call is not really necessary, right?  The two repos have no\n> common history (not even common patches).\n>\n> Besides, I think that what you did is just a complicated way of doing a\n> rebase.\nI tried rebase, wonderful!\n\n>\n> Ciao,\n> Dscho\n>\n>\n\n\n\n-- \nPing Yin\n"}]}