directory - How to turn a git repository into a subdirectory of a new repo? -


it turns out git repo created betters suits subdirectory, module x, of more general repository. how can copy original history (no signed commits) on such paths have prefix module x\?

i of course make moving subdirectory new commit, i'd prefer solution makes history if former repo in subdirectory.


i tried git subtree add --prefix="module x" ../module_x master temporary parallel folder fresh repository (since otherwise git subtree complains existing prefix), end with

fatal: ambiguous argument 'head': unknown revision or path not in working tree. use '--' separate paths revisions, this: 'git <command> [<revision>...] -- [<file>...]' working tree has modifications.  cannot add. 

this seems due lack of initial commit, because if i

touch .gitignore git add .gitignore git commit -m"init" 

it works, end original history in separate branch plus commit of moving, manual solution mentioned before...

git filter-branch --tree-filter 'mkdir -p module_x; mv files and* module_x/' head 

did trick. i'm using msysgit, guess in linux shopt -s extglob; mv !(module_x) module_x/ should work better...

if files explicitly mentioned have not existed through entire history, may have trick bit , append ; true --tree-filter such mv's non-zero exit code ignored.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -