Squash older commits while preserving active branches

Viewed 19

I want to reduce the repo size by around 90 percent without affecting much of the actively developed branches. So, I was wondering if it is possible to squash all the older commits while preserving the 10 - 15 active branches and their history up to a given commit. I am ideally looking for a way to convert the git repo history from

                     F1 - F2 - * - F3
                    /         /
                  C1 - C2 - C3 --------
                 /                     \
A1 - ... - An - B ----------------- * - * - B1
                 \                 /
                  D1 - D2 - D3 - D4
                    \                \
                     \                D5 - D6 - * - D7
                      \                        /
                       E1 - E2 ----------------

to

         F1 - F2 - * - F3
        /         /
      C1 - C2 - C3 --------
     /                     \
A - B ----------------- * - * - B1
     \                 /
      D1 - D2 - D3 - D4
        \                \
         \                D5 - D6 - * - D7
          \                        /
           E1 - E2 ----------------

It is acceptable even if the hash/commit ids of all the recent commits get updated as long as the branch structure and the merges remain the same. I tried to rebase all the active branches but that created several duplicate commits.

0 Answers
Related