# Trying to split repository

9 messages from 2009-10-01 to 2009-10-02. Participants: Josef Wolf, Adam Brewster, Tomas Carnecky, Jeff King.
Thread: https://gitlist.dev/t/21106

## Josef Wolf, 2009-10-01 16:03

Subject: Trying to split repository
Message-ID: <20091001160335.GA26068@raven.wolf.lan>
URL: https://gitlist.dev/e/20091001160335.GA26068%40raven.wolf.lan

```
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?

```

## Adam Brewster, 2009-10-01 16:49

Subject: Re: Trying to split repository
Message-ID: <c376da900910010949p197aa311l9c91ef711beffdf7@mail.gmail.com>
URL: https://gitlist.dev/e/c376da900910010949p197aa311l9c91ef711beffdf7%40mail.gmail.com
In-Reply-To: <20091001160335.GA26068@raven.wolf.lan>

```
>
> 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.

Adam

```

## Tomas Carnecky, 2009-10-01 16:49

Subject: Re: Trying to split repository
Message-ID: <427FD5A1-A416-424C-9F6F-35AE9E6F9E9B@dbservice.com>
URL: https://gitlist.dev/e/427FD5A1-A416-424C-9F6F-35AE9E6F9E9B%40dbservice.com
In-Reply-To: <20091001160335.GA26068@raven.wolf.lan>

```

On Oct 1, 2009, at 6:03 PM, Josef Wolf wrote:

> 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

```

## Josef Wolf, 2009-10-01 21:13

Subject: Re: Trying to split repository
Message-ID: <20091001211340.GB26068@raven.wolf.lan>
URL: https://gitlist.dev/e/20091001211340.GB26068%40raven.wolf.lan
In-Reply-To: <c376da900910010949p197aa311l9c91ef711beffdf7@mail.gmail.com>

```
On Thu, Oct 01, 2009 at 12:49:03PM -0400, Adam Brewster wrote:
> >
> > 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, 2009-10-02 00:47

Subject: Re: Trying to split repository
Message-ID: <c376da900910011747i894404dne1ea60dae5e3990b@mail.gmail.com>
URL: https://gitlist.dev/e/c376da900910011747i894404dne1ea60dae5e3990b%40mail.gmail.com
In-Reply-To: <20091001211340.GB26068@raven.wolf.lan>

```
>>
>> 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, 2009-10-02 00:52

Subject: [PATCH] filter-branch: add --prune-empty to option summary
Message-ID: <1254444731-6852-1-git-send-email-adambrewster@gmail.com>
URL: https://gitlist.dev/e/1254444731-6852-1-git-send-email-adambrewster%40gmail.com
In-Reply-To: <c376da900910011747i894404dne1ea60dae5e3990b@mail.gmail.com>

```
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, 2009-10-02 07:45

Subject: Re: [PATCH] filter-branch: add --prune-empty to option summary
Message-ID: <20091002074537.GA27664@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20091002074537.GA27664%40coredump.intra.peff.net
In-Reply-To: <1254444731-6852-1-git-send-email-adambrewster@gmail.com>

```
On Thu, Oct 01, 2009 at 08:52:11PM -0400, Adam Brewster wrote:

> 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, 2009-10-02 14:18

Subject: Re: [PATCH] filter-branch: add --prune-empty to option summary
Message-ID: <c376da900910020718i3ddc1dd1x5eb966a693b477e2@mail.gmail.com>
URL: https://gitlist.dev/e/c376da900910020718i3ddc1dd1x5eb966a693b477e2%40mail.gmail.com
In-Reply-To: <20091002074537.GA27664@coredump.intra.peff.net>

```
>
> 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, 2009-10-02 15:42

Subject: Re: Trying to split repository
Message-ID: <20091002154204.GC26068@raven.wolf.lan>
URL: https://gitlist.dev/e/20091002154204.GC26068%40raven.wolf.lan
In-Reply-To: <c376da900910011747i894404dne1ea60dae5e3990b@mail.gmail.com>

```
On Thu, Oct 01, 2009 at 08:47:15PM -0400, Adam Brewster wrote:
> >>
> >> 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!

```
