mpg (owner)

Revisions

gist: 137698 Download_button fork
public
Public Clone URL: git://gist.github.com/137698.git
Embed All Files: show embed
git-split.sh #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
 
# Split a git repo in multiple repositories, one per top-level directory.
#
# assume there are no spaces in dir names etc.
# assume the git repo is in the working directory
 
# Manuel Pégourié-Gonnard, 2009, WTFPLv2.
# This is gist #137698 <http://gist.github.com/137698>
 
REPO=$1
 
DOT=`pwd`
DIRS=`cd $REPO && echo *`
 
for DIR in $DIRS; do
if [ -d $REPO/$DIR ]; then
git clone file://$DOT/$REPO /tmp/$DIR;
        (cd /tmp/$DIR
        && git filter-branch --prune-empty --subdirectory-filter $DIR)
        git clone file:///tmp/$DIR $DIR;
        rm -rf /tmp/$DIR
        (cd $DIR && git remote rm origin)
    fi
done