{"thread":{"id":"26833","subject":"Re: How to remove a git subtree and its history?","startedAt":"2011-03-22T20:44:53Z","lastAt":"2011-03-23T17:09:21Z","messageCount":3,"participants":["Avery Pennarun","Robert Pollak"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"164087","messageId":"AANLkTiktAUeOkX0MZh+JbQb1z-JiN=Qet6_AuWavsNk=@mail.gmail.com","threadId":"26833","inReplyTo":"4D88A1CB.2000500@jku.at","subject":"Re: How to remove a git subtree and its history?","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2011-03-22T20:44:53Z","receivedAt":"2011-03-22T20:44:53Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Tue, Mar 22, 2011 at 6:19 AM, Robert Pollak <robert.pollak@jku.at> wrote:\n> in the git repository of my project I have successfully replaced a git\n> submodule by a subtree, essentially by using\n>\n> $git subtree add --prefix=mySubtree mySubmodule/master\n>\n> with your git-subtree.sh .\n>\n> Before accepting my change, my project partners want to be sure that\n> removing this new subtree and its history at some later point in time\n> stays possible. How can I achieve this? I have unsuccessfully tried \"git\n> filter-branch\" as described by pgs and fmarc in\n> http://stackoverflow.com/questions/955793#955793 .\n\nWell, you can certainly remove anything you want with git\nfilter-branch.  Are you concerned about shrinking the size of your\nrepo, or just getting files out of the way in your tree, or removing\nstuff from the git history?\n\nIf you want to avoid cluttering the git history, you should use git\nsubtree with the --squash option.  That makes it quite painless.\n\nIf you want to just get the files out of your tree someday in the\nfuture (for example, to switch back to submodules), then simply 'git\nrm -r' the directory.  Rewriting history is massive overkill for this.\n\nIf you want to be able to shrink your repository size later, well,\nthen you need git filter-branch.  I've never tried to do this since\nthe history rewrite you'd be doing in this case would completely\ninvalidate all your old history: by removing the subtree in all past\nrevisions, you make all those past revisions unbuildable, which seems\nlike missing the point of version control.  Nevertheless, I'm sure you\ncould make it happen if you wanted; you can do pretty much anything\nyou want by filtering git history.\n\n> (Be free to CC git@vger.kernel.org if you reply, if you think that's\n> appropriate for archiving the info.)\n\nI don't understand why you didn't cc: the git list yourself then.  But okay :)\n\nHave fun,\n\nAvery\n"},{"id":"164117","messageId":"4D89B6F4.2050209@jku.at","threadId":"26833","inReplyTo":"AANLkTiktAUeOkX0MZh+JbQb1z-JiN=Qet6_AuWavsNk=@mail.gmail.com","subject":"Re: How to remove a git subtree and its history?","fromName":"Robert Pollak","fromEmail":"robert.pollak@jku.at","sentAt":"2011-03-23T09:01:40Z","receivedAt":"2011-03-23T09:01:40Z","isPatch":false,"sender":{"key":"robert.pollak@jku.at","avatar":null},"body":"Am 22.03.2011 21:44, schrieb Avery Pennarun:\n> On Tue, Mar 22, 2011 at 6:19 AM, Robert Pollak <robert.pollak@jku.at> wrote:\n>> in the git repository of my project I have successfully replaced a git\n>> submodule by a subtree, essentially by using\n>>\n>> $git subtree add --prefix=mySubtree mySubmodule/master\n>>\n>> with your git-subtree.sh .\n>>\n>> Before accepting my change, my project partners want to be sure that\n>> removing this new subtree and its history at some later point in time\n>> stays possible. How can I achieve this? I have unsuccessfully tried \"git\n>> filter-branch\" as described by pgs and fmarc in\n>> http://stackoverflow.com/questions/955793#955793 .\n> \n> Well, you can certainly remove anything you want with git\n> filter-branch.  Are you concerned about shrinking the size of your\n> repo, or just getting files out of the way in your tree, or removing\n> stuff from the git history?\n> \n> If you want to avoid cluttering the git history, you should use git\n> subtree with the --squash option.  That makes it quite painless.\n> \n> If you want to just get the files out of your tree someday in the\n> future (for example, to switch back to submodules), then simply 'git\n> rm -r' the directory.  Rewriting history is massive overkill for this.\n> \n> If you want to be able to shrink your repository size later, well,\n> then you need git filter-branch.\n\nYes, I am aware of the other options and that's what I want to do.\n(I never really want to use this, I only need a test run to convince my\npartners to switch to git-subtree.)\n\n> I've never tried to do this since\n> the history rewrite you'd be doing in this case would completely\n> invalidate all your old history: by removing the subtree in all past\n> revisions, you make all those past revisions unbuildable, which seems\n> like missing the point of version control.  Nevertheless, I'm sure you\n> could make it happen if you wanted; you can do pretty much anything\n> you want by filtering git history.\n\nI see. As quite a git newbie I hoped you had done this already and could\nhelp me with the necessary git filter-branch command line.\n\n>> (Be free to CC git@vger.kernel.org if you reply, if you think that's\n>> appropriate for archiving the info.)\n> \n> I don't understand why you didn't cc: the git list yourself then.  But okay :)\n\nI was not sure whether discussion of git-subtree belongs there, since it\nis not part of git (yet?).\n\n> Have fun,\n\nI certainly do!\n\nThank you,\nRobert\n"},{"id":"164167","messageId":"AANLkTi=WX+jD-Vz0wtorHgMBQLQ4=ycHVzZeUt8goxyL@mail.gmail.com","threadId":"26833","inReplyTo":"4D89B6F4.2050209@jku.at","subject":"Re: How to remove a git subtree and its history?","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2011-03-23T17:09:21Z","receivedAt":"2011-03-23T17:09:21Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Wed, Mar 23, 2011 at 2:01 AM, Robert Pollak <robert.pollak@jku.at> wrote:\n> Am 22.03.2011 21:44, schrieb Avery Pennarun:\n>> I've never tried to do this since\n>> the history rewrite you'd be doing in this case would completely\n>> invalidate all your old history: by removing the subtree in all past\n>> revisions, you make all those past revisions unbuildable, which seems\n>> like missing the point of version control.  Nevertheless, I'm sure you\n>> could make it happen if you wanted; you can do pretty much anything\n>> you want by filtering git history.\n>\n> I see. As quite a git newbie I hoped you had done this already and could\n> help me with the necessary git filter-branch command line.\n\nI don't really have time to decode it all for you, but there are\nbasically two things you need to do here:\n\n1) filter out the subtree merge commits\n2) filter out the actual files.\n\nYou didn't really say which part of git-filter-branch *didn't* work\nfor you.  I'm assuming you were successful at #2, since that part\ncomes straight out of the filter-branch documentation, and you ended\nup with some leftover git history (ie. log entries from the parent\nproject) that you don't want to see.\n\nThe easiest way I know to remove commits from the middle of history\n(other than rebase, but that's too painful when there are merges) is\nto use grafts: https://git.wiki.kernel.org/index.php/GraftPoint\n\nOr maybe 'git replace' is easier than grafts nowadays.\n\nAfter replacing the offending merge commits, run filter-branch one\nmore time to make the changes permanent.\n\n>>> (Be free to CC git@vger.kernel.org if you reply, if you think that's\n>>> appropriate for archiving the info.)\n>>\n>> I don't understand why you didn't cc: the git list yourself then.  But okay :)\n>\n> I was not sure whether discussion of git-subtree belongs there, since it\n> is not part of git (yet?).\n\nThe git list seems to be used for discussion of git side projects\nsometimes.  As it happens, I'm not subscribed to the list anymore\n(nothing personal; I just can't handle the volume right now), so it's\nimportant to leave me on the cc: list though if you want me to see it.\n\nHave fun,\n\nAvery\n"}]}