
Untitled
By: a guest on
Apr 24th, 2012 | syntax:
None | size: 0.73 KB | hits: 6 | expires: Never
git-filter-branch: leave directory structure
|-repository/
| | |-repository/fileOne
| |
| |-subOne/
| | |-subOne/fileTwo
| |
| |-subTwo/
| |-subTwo/fileThree
$ git filter-branch --subdirectory-filter subOne --prune-empty
$ git log --oneline
0c0ea11 subOne history
6318bba subOne history
c96fddb Initial commit
$ ls
fileOne
$ pwd
/this/is/a/path/repository
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