Create new git repo from already existing repo's subdirectory -



Create new git repo from already existing repo's subdirectory -

i want create separate repo existing repo's subfolder.

detach subdirectory separate git repository shows that. but, can't clean repo it. end 2 problems new repo:

the history seems duplicated; i can't maintain branches history.

here did:

$ git clone ssh://.../repo.git $ cd repo $ git filter-branch --subdirectory-filter subdirectory head -- --all $ git reset --hard $ git gc --aggressive $ git prune

after this, seems have original history of repo , new history. type "git log --all --graph" (or gitk --all) see, first commit, initial commit of first repo. graph shows original repo's total history until lastly commit. then, have sec history on top of first 1 showing history of subfolder want. in part of history have "master" , no branches/merges.

"git log", gitk or gitg show "flatten" history only: don't show initial repo's history before the subfolder's flatten history.

i tried using "filter-branch" command, cloning resulting repo (with --no-hardlinks), using:

$ git filter-branch --subdirectory-filter subdirectory -- --all

instead of:

$ git filter-branch --subdirectory-filter subdirectory head -- --all

but same result.

am doing wrong or git broken? i'm out of ideas... using git 1.7.6. thanks.

edit: think problem might come fact merge commits ignored filter-branch, giving flat history no branches or merges...

you have 2 problems here:

(1) kevin ballard points out, need delete refs/original directory in .git directory rid of spurious log entries; iirc mentioned in question referred to.

(2) have convert branches 1 @ time. far know, isn't mentioned anywhere, it's pretty easy find empirically. script this:

for branch in $(git for-each-ref --format='%(refname:short)' refs/remotes/origin | grep -v head); git checkout -b $(basename $branch) $branch git filter-branch -f --subdirectory-filter subdirectory head -- --all done

note need -f or else --original $(basename $branch)-original forcefulness git reuse or rename namespace stores original refs. note may see messages "found nil rewrite" if subdirectory not exist on particular branch -- want delete branches new repository. (or delete them before running script.)

git

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -