I'm currently trying to reduce the size of my Git repository but faced many issues.
Introduction
I have a huge and complex Git repository containing thousands of commits and more than ten branches. It's current size is over 2 GB.
What I want to do
I would like to clean the repository history in order to reduce its size as much as possible. I chose a special commit that I want to be my new root commit (call it <NEW_ROOT>
); I want to remove every commit before <NEW_ROOT>
and keep all the commits after.
I want to keep only master
and, possibly, develop
branches, any other branch should be removed from history to reduce size.
At the end of the procedure I want to push everything to remote, so that it only keeps updated master and origin (basically it must reflect my local situation).
What I tried so far
I browsed the web a lot and found many solutions, but none of them worked for me. In particular I guess that such a solution would be perfect in my case, unfortunately I got a lot of conflicts when rebasing.
I also struggled a lot because many solutions I found refers to obsolete and deprecated tools/options (e.g. git filter-branch
).
Could you please help me find a way out?
Thanks a lot!