Hello I have successfully rewrote history and got the 5 folders I wanted to extract using git filter-branch -f --prune-empty --tree-filter 'rm -rf <all unwanted dirs>'
and kept all git history.
The only remaining issue are submodules, I sill have commits doing
Subproject commit <hash>
and I want to completely remove ALL of those submodule commits from my git history, how can I accomplish this?
git-filter-branch can be used to get rid of a subset of files, usually with some combination of --index-filter and --subdirectory-filter .
Pulling with submodules. Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .
If you want to check for new work in a submodule, you can go into the directory and run git fetch and git merge the upstream branch to update the local code. Now if you go back into the main project and run git diff --submodule you can see that the submodule was updated and get a list of commits that were added to it.
I have done it with
git filter-branch -f --prune-empty --tree-filter '
git submodule deinit -f .
git rm -rf lib && rm -rf lib
find . -name .gitmodules -delete' HEAD
Assuming that all of my submodules were located in lib
directory
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