Skip to contentSkip to conversation

Trying to split repository

PATCH In review Josef Wolf 4 participants 9 messages Jun 15, 2016 Documentation

lore
Share & tools
lore

Josef Wolf

author
#0 lore raw

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?

#1 lore raw
Quoted 5 lines · Josef Wolf

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

#2 lore raw
In reply to Josef Wolf
Quoted 2 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.

Adam

author
#3 lore raw
Quoted 5 lines · Adam Brewster
Quoted 2 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?

#4 lore raw
Quoted 7 lines
Quoted 3 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

#5 lore raw

PATCH 1/1 filter-branch: add --prune-empty to option summary

---
 Documentation/git-filter-branch.txt |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Documentation/git-filter-branch.txt +1 -0
index 451950b..2cc3bd8 100644
@@ -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>...]
 
Signature · 1 line
1.6.0.6
#6 lore raw

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

Documentation/git-filter-branch.txt SYNOPSIS · line 17

Quoted 11 lines · Adam Brewster
Documentation/git-filter-branch.txt +1 -0
index 451950b..2cc3bd8 100644
@@ -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

#7 lore raw

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

Quoted 3 lines

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

author
#8 lore raw
In reply to Adam Brewster
Quoted 11 lines · Adam Brewster
Quoted 5 lines
Quoted 3 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!