Cleaning up the git history with many Openfire plugins

When we split the source code for various openfire plugins out of the main Openfire git repo, which created individual repos for each plugin, we had a problem with lots of unrelated Openfire commit history coming along for the ride. See this forums post for example problem this caused. The main issue being a bloated repo (~500 MB) with 5,500 commits!

I am keen on attempting to fix this situation, which currently requires a force-push due to other complicated issues with how the present git history was constructed. To document the procedure I am doing and to solicit comments:

  1. Clone the Openfire repo
    git clone https://github.com/Igniterealtime/Openfire.git
  2. Create a MYFILES.txt file containing file paths to save whilst running git filter-repo
$ cat MYFILES
src/plugins/pluginname
plguins/pluginname
  1. run git filter-repo -f --paths-from-file MYFILES
  2. back up one commit, to remove the commit that deleted the plugin git reset --hard HEAD~1
  3. do a manual move of the plugin/pluginname content to the root folder of the repo, commit that change effectively bringing the repo tree inline with the present upstream repo.
  4. fetch the master branch of the plugin of interest git remote add upstream https://github.com/igniterealtime/openfire-pluginname-plugin.git; git fetch upstream master
  5. By inspecting the git log, find a series of commits from the current master branch to cherry-pick here, so git cherry-pick --strategy=recursive -X theirs rev1^...revn, manual merging is then hopefully not necessary.
  6. Update the readme to denote this git history rewrite and link to this very post :slight_smile:
  7. Force push to the igniterealtime repo!

What do folks think of this? Anybody with stronger git foo to suggest otherwise? :slight_smile:

As a sample, you can see what I did to the openfire-loadStats-plugin repo (67 commits, 200 KB in size).

1 Like

Except for the monitoring plugin, which has more outstanding PRs than I wish to fix, I believe all the bloated openfire plugin repos are now fixed. I have full backups of the repositories if anything bad is discovered. This was an ugly thorn in the developers side for a while, glad we are hopefully past it.

2 Likes

I have now updated the monitoring plugin repository as well. Again, we are sorry this happened and know this will create some pain for the forked repositories.

1 Like

What’s the best way to reset (the main branch of) a fork of the affected repositories?

What I’m doing so far is:

git remote add upstream /url/to/original/repo
git fetch upstream
git checkout master
git reset --hard upstream/master  
git push origin master --force 

Obviously, this wipes all changes that were in the original branch!

I think so, but you probably would want to push --tags as well and then delete any old tags too so to remove any old commit references. If you did not have any code modifications or custom trees in your fork, it is likely easier to just delete your fork via github UI and fork it again.