I have a big main project with several directories as subtrees.
I want to push the changes in one specific subtree to its origin, which is a separate repository.
The trouble seems to be, that the current subtree I want to push does not originally came from the repository I want to push into. It came from a different repo, via the subtree guides I found by googling. It just looks very similar.
Big project layout, where
important_subtree is the thing I am worried about.
efg.txt <--- new version
important_subtree is "strongly related" to that repo:
efg.txt <--- old version
~/devel/bigproject/important_subtree/efg.txt has changed and I want to push the important_subtree onto the repo
~/devel/important. So afterwards
~/devel/important/efg.txt also has the changes.
The only thing I managed to do is to push push everything in bigproject into important, which is obviously not what I want. Only the changes in the subtree should be pushed.
This is no longer so complex, you can just use the git filter-branch command on a clone of your repo to cull the subdirectories you don't want and then push to the new remote.
git clone <ORIG_REPO_DIR> <NEW_REPO_DIR>
git filter-branch --prune-empty --subdirectory-filter <THE_SUBDIR_TO_MAKE_NEW_ROOTDIR> master
git push <MY_NEW_REMOTE_ORIGIN_URL> -f .
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