Let's say there is repo-source
that has sub-directory z
under x/y
which we want to move to repo-target
:
- go to source repo -
cd repo-source
- extract files from
z
into a new branchz-only
-git subtree split -P x/y/z -b z-only
Now if we checkout to z-only
branch all files from x/y/z
will be in the root directory.
In order to preserve original directory structure move directories/files into x/y/z
manually:
- re-create
x/y/z
directory -mkdir -P x/y/z
(mkdir x\y\z
on Windows)