git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: How to remove a git subtree and its history?
       [not found] <4D88A1CB.2000500@jku.at>
@ 2011-03-22 20:44 ` Avery Pennarun
  2011-03-23  9:01   ` Robert Pollak
  0 siblings, 1 reply; 3+ messages in thread
From: Avery Pennarun @ 2011-03-22 20:44 UTC (permalink / raw)
  To: Robert Pollak; +Cc: Git Mailing List

On Tue, Mar 22, 2011 at 6:19 AM, Robert Pollak <robert.pollak@jku.at> wrote:
> in the git repository of my project I have successfully replaced a git
> submodule by a subtree, essentially by using
>
> $git subtree add --prefix=mySubtree mySubmodule/master
>
> with your git-subtree.sh .
>
> Before accepting my change, my project partners want to be sure that
> removing this new subtree and its history at some later point in time
> stays possible. How can I achieve this? I have unsuccessfully tried "git
> filter-branch" as described by pgs and fmarc in
> http://stackoverflow.com/questions/955793#955793 .

Well, you can certainly remove anything you want with git
filter-branch.  Are you concerned about shrinking the size of your
repo, or just getting files out of the way in your tree, or removing
stuff from the git history?

If you want to avoid cluttering the git history, you should use git
subtree with the --squash option.  That makes it quite painless.

If you want to just get the files out of your tree someday in the
future (for example, to switch back to submodules), then simply 'git
rm -r' the directory.  Rewriting history is massive overkill for this.

If you want to be able to shrink your repository size later, well,
then you need git filter-branch.  I've never tried to do this since
the history rewrite you'd be doing in this case would completely
invalidate all your old history: by removing the subtree in all past
revisions, you make all those past revisions unbuildable, which seems
like missing the point of version control.  Nevertheless, I'm sure you
could make it happen if you wanted; you can do pretty much anything
you want by filtering git history.

> (Be free to CC git@vger.kernel.org if you reply, if you think that's
> appropriate for archiving the info.)

I don't understand why you didn't cc: the git list yourself then.  But okay :)

Have fun,

Avery

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to remove a git subtree and its history?
  2011-03-22 20:44 ` How to remove a git subtree and its history? Avery Pennarun
@ 2011-03-23  9:01   ` Robert Pollak
  2011-03-23 17:09     ` Avery Pennarun
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Pollak @ 2011-03-23  9:01 UTC (permalink / raw)
  To: Avery Pennarun; +Cc: Git Mailing List

Am 22.03.2011 21:44, schrieb Avery Pennarun:
> On Tue, Mar 22, 2011 at 6:19 AM, Robert Pollak <robert.pollak@jku.at> wrote:
>> in the git repository of my project I have successfully replaced a git
>> submodule by a subtree, essentially by using
>>
>> $git subtree add --prefix=mySubtree mySubmodule/master
>>
>> with your git-subtree.sh .
>>
>> Before accepting my change, my project partners want to be sure that
>> removing this new subtree and its history at some later point in time
>> stays possible. How can I achieve this? I have unsuccessfully tried "git
>> filter-branch" as described by pgs and fmarc in
>> http://stackoverflow.com/questions/955793#955793 .
> 
> Well, you can certainly remove anything you want with git
> filter-branch.  Are you concerned about shrinking the size of your
> repo, or just getting files out of the way in your tree, or removing
> stuff from the git history?
> 
> If you want to avoid cluttering the git history, you should use git
> subtree with the --squash option.  That makes it quite painless.
> 
> If you want to just get the files out of your tree someday in the
> future (for example, to switch back to submodules), then simply 'git
> rm -r' the directory.  Rewriting history is massive overkill for this.
> 
> If you want to be able to shrink your repository size later, well,
> then you need git filter-branch.

Yes, I am aware of the other options and that's what I want to do.
(I never really want to use this, I only need a test run to convince my
partners to switch to git-subtree.)

> I've never tried to do this since
> the history rewrite you'd be doing in this case would completely
> invalidate all your old history: by removing the subtree in all past
> revisions, you make all those past revisions unbuildable, which seems
> like missing the point of version control.  Nevertheless, I'm sure you
> could make it happen if you wanted; you can do pretty much anything
> you want by filtering git history.

I see. As quite a git newbie I hoped you had done this already and could
help me with the necessary git filter-branch command line.

>> (Be free to CC git@vger.kernel.org if you reply, if you think that's
>> appropriate for archiving the info.)
> 
> I don't understand why you didn't cc: the git list yourself then.  But okay :)

I was not sure whether discussion of git-subtree belongs there, since it
is not part of git (yet?).

> Have fun,

I certainly do!

Thank you,
Robert

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to remove a git subtree and its history?
  2011-03-23  9:01   ` Robert Pollak
@ 2011-03-23 17:09     ` Avery Pennarun
  0 siblings, 0 replies; 3+ messages in thread
From: Avery Pennarun @ 2011-03-23 17:09 UTC (permalink / raw)
  To: Robert Pollak; +Cc: Git Mailing List

On Wed, Mar 23, 2011 at 2:01 AM, Robert Pollak <robert.pollak@jku.at> wrote:
> Am 22.03.2011 21:44, schrieb Avery Pennarun:
>> I've never tried to do this since
>> the history rewrite you'd be doing in this case would completely
>> invalidate all your old history: by removing the subtree in all past
>> revisions, you make all those past revisions unbuildable, which seems
>> like missing the point of version control.  Nevertheless, I'm sure you
>> could make it happen if you wanted; you can do pretty much anything
>> you want by filtering git history.
>
> I see. As quite a git newbie I hoped you had done this already and could
> help me with the necessary git filter-branch command line.

I don't really have time to decode it all for you, but there are
basically two things you need to do here:

1) filter out the subtree merge commits
2) filter out the actual files.

You didn't really say which part of git-filter-branch *didn't* work
for you.  I'm assuming you were successful at #2, since that part
comes straight out of the filter-branch documentation, and you ended
up with some leftover git history (ie. log entries from the parent
project) that you don't want to see.

The easiest way I know to remove commits from the middle of history
(other than rebase, but that's too painful when there are merges) is
to use grafts: https://git.wiki.kernel.org/index.php/GraftPoint

Or maybe 'git replace' is easier than grafts nowadays.

After replacing the offending merge commits, run filter-branch one
more time to make the changes permanent.

>>> (Be free to CC git@vger.kernel.org if you reply, if you think that's
>>> appropriate for archiving the info.)
>>
>> I don't understand why you didn't cc: the git list yourself then.  But okay :)
>
> I was not sure whether discussion of git-subtree belongs there, since it
> is not part of git (yet?).

The git list seems to be used for discussion of git side projects
sometimes.  As it happens, I'm not subscribed to the list anymore
(nothing personal; I just can't handle the volume right now), so it's
important to leave me on the cc: list though if you want me to see it.

Have fun,

Avery

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-23 17:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4D88A1CB.2000500@jku.at>
2011-03-22 20:44 ` How to remove a git subtree and its history? Avery Pennarun
2011-03-23  9:01   ` Robert Pollak
2011-03-23 17:09     ` Avery Pennarun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).