Windows Git 2.20.0 Using Bash (and windows command line git) both same result.
Is there an accepted and SAFE way to extract a folder from a large repository and move it into its own REPO whilst keeping the link back to the large repo for synchronizing back to the main code base?
GROUP
Company1
Apps
SharedApp
Company2
Apps
I want to extract SharedApp out into its own repo but keep it linked with GROUP if possible. so if someone checks out GROUP they get the whole lot, but a 3rd party Dev can check out just the Apps folder.
I have tried using:
git filter-branch --prune-empty --subdirectory-filter SharedApp
but this just returns "Found nothing to rewrite"
I have also tried:
git subtree -P SharedApp -b newbranch
But this just puts the entire structure set on a new branch "newbranch" and doesn't filter anything as (I thought) the docs say it should.
Have considered using SubRepos but i hear they are particularly troublesome down the line.
Any help greatly appreciated.
edit: at some point i need to do this for a LOT of folder and libraries and link them back into the main repo. hence the question.
I don't understand your emphasis on "SAFE". You are using git - anything you do to a clone affects only that clone. So long as you verify what you've done locally before affecting the remote, you shouldn't be able to lose anything. What is the risk you're concerned about?
If you use filter-branch
, you won't have an easy way to integrate future changes between the repos. Not that there's no way to do it, but it requires jumping through significant hoops because the result is not linked to the original.
That said, if you want to use filter-branch
: One reason it would do that is if the path isn't specified correctly. Make sure you're giving the full path from the worktree root, and depending on your file system capitalization may matter. (On windows it doesn't normally matter; Mac or *nix it probably does.) If there is a SharedApp directory with files in it committed directly under the repo root, the filter argument as given should be fine.
Also, you probably need to add a --all
argument (or one or more branch names) so it knows what to rewrite.
git filter-branch --prune-empty --subdirectory-filter SharedApp -- --all
In my opinion subrepos are the closest thing git offers to what you're asking for. Yes, a lot of people don't like them; then again, a lot of other people use them just fine. You have to take the time to understnad how to work with them, and not expect them to work a different way than they work, or else not use them.