I know this is unusual, but one of my git repo, which acts as a collect-all repo, is getting too big and I'd like to split it up in two, into repoA
and repoB
.
I've found one way to do the splitting in "Forking a sub directory of a repository on GitHub and making it part of my own repo", however, that only tells about splitting, I want the history to be split as well, so repoA
will only contain history of repoA
and not repoB
, and vice versa. Otherwise, I'll get two repos but double the size because of all the history it is keeping.
UPDATE:
Thanks to @ElpieKay pointing out to look at git filter-branch
(instead of the git clean
that I found when searching with "git purge"), I found this:
https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/
which is exactly what I was looking for. However, there is one more question -- how to remove repoA
content from repoB
? I.e., when splitting out repoA
, I only need to do,
git filter-branch --prune-empty --subdirectory-filter sub1/sub2/sub3 master
So in repoB
, how to remove sub1/sub2/sub3
while keep everything else?
Moreover, this command in above doc,
git remote set-url origin https://github.com/USERNAME/NEW-REPOSITORY-NAME.git
When I tried it, it only updated the fetch
url, and the push
one is still pointing to the old one. What I'm missing?