I want to create a separate repo from an already existing repo's subfolder.
Detach (move) subdirectory into separate Git repository shows exactly that. BUT, I can't get a clean repo with it. I end up with two problems with the new repo:
Here is what I 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, it seems I have the original history of the repo AND the new history. I type "git log --all --graph" (or gitk --all) I see, as the first commit, the initial commit of the first repo. The graph then shows the original repo's full history until the last commit. Then, I have a SECOND history on top of the first one showing the history of only the subfolder I want. But in that part of the history I only have "master" and no branches/merges.
"git log", gitk or gitg all show the "flatten" history only: they don't show the initial repo's history before the the subfolder's flatten history.
I tried using just the "filter-branch" command, cloning the resulting repo (with --no-hardlinks), using:
$ git filter-branch --subdirectory-filter subdirectory -- --all
instead of:
$ git filter-branch --subdirectory-filter subdirectory HEAD -- --all
But with the same result.
Am I am doing something wrong or git is broken? I'm really out of ideas... Using git 1.7.6. Thanks.
EDIT: I think the problem might come from the fact that merge commits are ignored by filter-branch, thus giving a flat history with no branches or merges...
Github has a straight forward method:
https://help.github.com/articles/splitting-a-subpath-out-into-a-new-repository
git clone git://github.com/defunkt/github-gem.git
cd github-gem/
Change directory into the repository
git filter-branch --prune-empty --subdirectory-filter lib master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With