threads / discuss / 21106

Trying to split repository

Subject: Trying to split repository

## tl;dr

9 messages between Oct 1, 2009 and Oct 2, 2009.

replies: 8people: 4as markdown or json

Josef Wolf· Oct 1, 2009, 16:03 UTC · lore
Hello,

One of my repositories has grown a subdirectory that I'd like to split off, so other can use it as a subproject. With the help of google, I found this solution:

    # first extract the library from the original repository
    #
    git clone --no-hardlinks repository library.tmp
    (
        cd library.tmp
        git filter-branch --subdirectory-filter CF -- --all
        git reset --hard
        git gc --aggressive
        git prune
        git gc
        git clone --bare . ../library
    )
    rm -rf library.tmp
    # Now remove the library from the original repository, so it can be
    # included as a subproject
    #
    git clone --no-hardlinks repository repository.new.tmp
    (
        cd repository.new.tmp
        git filter-branch \
            --index-filter "git rm -r -f --cached --ignore-unmatch CF" \
            -- --all
        git reset --hard
        git gc --aggressive
        git prune
        git gc
        git clone --bare . ../repository.new
    )
    rm -rf repository.new.tmp

This works fine. But there's one problem, though. "gitk --all" in the new repository still shows all the history of the removed library. The patch show no modifications, but the log entry is still there.

Any hints how to get rid of those log entries?
Josef Wolf· Oct 1, 2009, 21:13 UTC · re: Adam Brewster · lore

Re: Trying to split repository

On Thu, Oct 01, 2009 at 12:49:03PM -0400, Adam Brewster wrote:
Show 5 quoted lines
> >
> > Any hints how to get rid of those log entries?
> 
> git-filter-branch accepts a --prune-empty option that does what I
> think you're looking for.
Thanks for your answer, Adam!
Is this a new option? 1.6.0.2 don't seem to have it?
Adam Brewster· Oct 2, 2009, 00:47 UTC · re: Josef Wolf · lore

Re: Trying to split repository

Show 7 quoted lines
>>
>> git-filter-branch accepts a --prune-empty option that does what I
>> think you're looking for.
>
> Thanks for your answer, Adam!
>
> Is this a new option? 1.6.0.2 don't seem to have it?
1.6.0.2 was released September 2008 (git log -n1 v1.6.0.2).

This feature was added in October 2008. (git blame Documentation/git-filter-branch.txt; git log -n1 d3240d93).

It's still it is missing from the option summary in master though.
Adam
Adam Brewster· Oct 2, 2009, 00:52 UTC · re: Adam Brewster · lore

[PATCH] filter-branch: add --prune-empty to option summary

Signed-off-by: Adam Brewster <adambrewster@gmail.com>
---
 Documentation/git-filter-branch.txt |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 451950b..2cc3bd8 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -12,6 +12,7 @@ SYNOPSIS
 	[--index-filter <command>] [--parent-filter <command>]
 	[--msg-filter <command>] [--commit-filter <command>]
 	[--tag-name-filter <command>] [--subdirectory-filter <directory>]
+	[--prune-empty]
 	[--original <namespace>] [-d <directory>] [-f | --force]
 	[--] [<rev-list options>...]
 
-- 
1.6.0.6
Jeff King· Oct 2, 2009, 07:45 UTC · re: Adam Brewster · lore

Re: [PATCH] filter-branch: add --prune-empty to option summary

On Thu, Oct 01, 2009 at 08:52:11PM -0400, Adam Brewster wrote:
Show 11 quoted lines
> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
> index 451950b..2cc3bd8 100644
> --- a/Documentation/git-filter-branch.txt
> +++ b/Documentation/git-filter-branch.txt
> @@ -12,6 +12,7 @@ SYNOPSIS
>  	[--index-filter <command>] [--parent-filter <command>]
>  	[--msg-filter <command>] [--commit-filter <command>]
>  	[--tag-name-filter <command>] [--subdirectory-filter <directory>]
> +	[--prune-empty]
>  	[--original <namespace>] [-d <directory>] [-f | --force]
>  	[--] [<rev-list options>...]

Thanks. This makes sense given the existing structure, though I have to wonder how useful some of these gigantic synopses really are. Do we really need to list all of the options here in a cluttered, annoyingly wrapped format, when we are just going to list them in a nice easy-to-read format with their descriptions later on in the page?

And this is really not so much to do with your patch as a meta-rant, so feel free to stop reading.

What should the synopsis really be communicating? In something like git-cat-file(1), the synopsis nicely shows a few key facts:

  1. There are two "modes" if invocation.
  2. In one mode, you give an action and an object on the command line.
  3. In the other mode, you give --batch and feed some stuff over stdin.

Those are all useful pieces of information, and they are communicated more quickly than they would be by forcing me to read the paragraph-formatted text of the description section.

But look at the 18-line synopsis for git-grep or the 17-line one for git-format-patch. Are they really helping anyone? (And it is not just the line count. The 18-line synopsis for git-config is actually useful, because there really are 18 modes of operation).

Non-git programs seem to take a more sparse approach. For example, some one-line synopses from my system:

       sed [OPTION]... {script-only-if-no-other-script} [input-file]...
       ls [OPTION]... [FILE]...
or even this longer one:
       vim [options] [file ..]
       vim [options] -
       vim [options] -t tag
       vim [options] -q [errorfile]

Those all communicate some useful information (how to generally invoke the program) cluttering it with redundant information.

-Peff
Adam Brewster· Oct 2, 2009, 14:18 UTC · re: Jeff King · lore

Re: [PATCH] filter-branch: add --prune-empty to option summary

>
> Thanks. This makes sense given the existing structure, though I have to
> wonder how useful some of these gigantic synopses really are.

I find them useful mostly when dealing with commands that I generally know, but don't remember the exact spelling or ordering of the options. I might forget, for example, if it's --msg-filter or --message-filter.

Adam
Josef Wolf· Oct 2, 2009, 15:42 UTC · re: Adam Brewster · lore

Re: Trying to split repository

On Thu, Oct 01, 2009 at 08:47:15PM -0400, Adam Brewster wrote:
Show 11 quoted lines
> >>
> >> git-filter-branch accepts a --prune-empty option that does what I
> >> think you're looking for.
> > Thanks for your answer, Adam!
> > Is this a new option? 1.6.0.2 don't seem to have it?
> 1.6.0.2 was released September 2008 (git log -n1 v1.6.0.2).
> 
> This feature was added in October 2008.  (git blame
> Documentation/git-filter-branch.txt; git log -n1 d3240d93).
> 
> It's still it is missing from the option summary in master though.
Thanks for clarifying that, Adam!
Tomas Carnecky· Oct 1, 2009, 16:49 UTC · re: Josef Wolf · lore

Re: Trying to split repository

On Oct 1, 2009, at 6:03 PM, Josef Wolf wrote:
Show 7 quoted lines
> Hello,
>
> One of my repositories has grown a subdirectory that I'd like to  
> split off,
> so other can use it as a subproject. With the help of google, I  
> found this
> solution:
Take a look at git-subtree (http://github.com/apenwarr/git-subtree).
tom

← back to recent threads