git-filter-branch: leave the directory structure unchanged

I have a directory structure in my repository:

|-repository/
|  |  |-repository/fileOne
|  |
|  |-subOne/
|  |  |-subOne/fileTwo
|  |
|  |-subTwo/
|     |-subTwo/fileThree

I want to move the directory subOneto another repository. For this, I split subOneusing git-filter-branchas follows:

$ git filter-branch --subdirectory-filter subOne --prune-empty

This leaves me with a branch history that looks like this:

$ git log --oneline
0c0ea11 subOne history
6318bba subOne history
c96fddb Initial commit

This is exactly what I want; from another repository I can do git fetchand git merge, which adds subOnehistory to another repository. It's great.

However git-filter-branchdeleted subOne. Checking the directory structure on my branch:

$ ls
fileOne
$ pwd
/this/is/a/path/repository

pwd should read: /this/is/a/path/repositorybut lsshould show subOneinside the repository. Instead, I have files subOnemoved up, and the directory is deleted.

subOne ?

+5
1

pwd :/this/is/a/path/repository, ls subOne . subOne, , .

, git-filter-branch --subdirectory-filter. man git-filter-branch:

( ) .

, / /subdirectory. , man git-filter-branch , , EXAMPLES:

To move the whole tree into a subdirectory, or remove it from there:
       git filter-branch --index-filter \
               'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
                       GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                               git update-index --index-info &&
                mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD

EDIT: MAC OS X. . . BSD sed GNU sed, . OS X, sed gsed; .

+5

All Articles