1GIT-CLONE-SUBSET(1)         General Commands Manual        GIT-CLONE-SUBSET(1)
2
3
4

NAME

6       git-clone-subset - Clones a subset of a git repository
7

SYNOPSIS

9       git-clone-subset [options] repository destination-dir pattern
10

DESCRIPTION

12       Clones a repository into a destination-dir and runs on the clone
13       git filter-branch --prune-empty --tree-filter 'git rm ...' -- --all
14       to prune from history all files except the ones matching pattern,
15       effectively creating a clone with a subset of files (and history) of
16       the original repository.
17
18       Useful for creating a new repository out of a set of files from another
19       repository, migrating (only) their associated history. Very similar to
20       what
21       git filter-branch --subdirectory-filter
22       does, but for a file pattern instead of just a single directory.
23

OPTIONS

25       -h, --help
26               show usage information.
27
28       repository
29               URL or local path to the git repository to be cloned.
30
31       destination-dir
32               Directory to create the clone. Same rules for git-clone
33               applies: it will be created if it does not exist and it must be
34               empty otherwise.  But, unlike git-clone, this argument is not
35               optional: git-clone uses several rules to determine the
36               "Humane" dir name of a cloned repo, and git-clone-subset will
37               not risk parse its output, let alone predict the chosen name.
38
39       pattern Glob pattern to match the desired files/dirs. It will be
40               ultimately evaluated by a call to bash, NOT git or sh, using
41               extended glob '!(<pattern>)' rule. Quote it or escape it on
42               command line, so it does not get evaluated prematurely by your
43               current shell. Only a single pattern is allowed: if more are
44               required, use extglob's "|" syntax. Globs will be evaluated
45               with bash's shopt dotglob set, so beware. Patterns should not
46               contain spaces or special chars like " ' $ ( ) { } `, not even
47               quoted or escaped, since that might interphere with the !()
48               syntax after pattern expansion.
49
50               Pattern Examples:
51
52               "*.png"
53               "*.png|*icon*"
54               "*.h|src/|lib"
55

LIMITATIONS

57       Renames are NOT followed. As a workaround, list the rename history with
58       'git log --follow --name-status --format='%H' -- file | grep "^[RAD]"'
59       and include all multiple names of a file in the pattern, as in
60       "currentname|oldname|initialname". As a side efect, if a different file
61       has taken place of an old name, it will be preserved too, and there is
62       no way around this using this tool.
63
64       There is no (easy) way to keep some files in a dir: using 'dir/foo*' as
65       pattern will not work. So keep the whole dir and remove files
66       afterwards, using git filter-branch and a (quite complex) combination
67       of cloning, remote add, rebases, etc.
68
69       Pattern matching is quite limited, and many of bash's escaping and
70       quoting does not work properly when pattern is expanded inside !().
71

SEE ALSO

73       https://github.com/MestreLion/git-tools
74

AUTHOR

76       Rodrigo Silva (MestreLion) linux@rodrigosilva.com
77
78
79
80                                  2016-01-31               GIT-CLONE-SUBSET(1)
Impressum