简体   繁体   中英

git subtree changes the package directory

I'm using git subtree to split specific package of a java project into another repository (retaining the history) as the following

$ git subtree split -P src/main/java/com/company/package -b moved_package_branch

then when switch to this branch I find that all the content of the package is moved to the root of the project not to it original place (src/main/java/com/company/package)

Any idea about how to fix it?

I have used another git command than subtree as the following

$ git checkout -b moved_package_branch
$ git filter-branch --index-filter 'git rm --cached -qr -- . && git reset -q $GIT_COMMIT -- src/main/java/com/company/package' --prune-empty

Note that you can include multiple folders (space separated)

Reference: last answer from @David Smiley

Detach many subdirectories into a new, separate Git repository

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM