Hi all,
I have git repositories rA and rB, I would like to copy only specific directories in rA and preserving their history, e.g.
rA
- d1
- d2
- d3
- d4
rB (with d1 and d2 preserved)
- d1
- d2
What I have done so far is:
git remote add -f rA /path/to/rA
git merge -s ours --no-commit rA/master
That gives me all the files in rA
and I am wondering if I can use commands such as git-filter-branch
to exclude d3
and d4
? Or I am having a terribly wrong concept on how repositories are treated and managed?
Thanks.
Updated:
I made this possible by:
- Duplicate (cp -R) my existing repository to a dir.
Perform this command on this new dir:
git filter-branch --index-filter 'git rm --cached -rgit ls-tree --name-only --full-tree -r $GIT_COMMIT | grep -Ev "^dirs|to|be|included" | xargs -r git rm --cached -r; fi' -- --all
Carried on the steps I mentioned earlier.