So, someone pushed a large file to a repo in our Bitbucket (we use Bitbucket Server, so it's hosted by us). We have deleted the file but want to get rid in history too as the repo is now quite large to clone.
We can see how to get rid of the large file in a clone of the repo. We have done that using git-filter-repo
.
However, this repo is central to our CI system and we can't move or rename it easily. So, I want to perform the same operation directly on the repo used by the bitbucket server. That is proving tricky. I found where the repo is (thanks to this answer). I logged in to the server and went to $BITBUCKET_HOME/shared/data/repositories/<id>
and tried running the git-filter-repo
command there but it failed with
Parsed 2203 commits
Required environment variable STASH_HOOK_ADDRESS is missing
Required environment variable STASH_HOOK_ADDRESS is missing
fatal: ref updates aborted by hook
fast-import: dumping crash report to fast_import_crash_22581
Error: fast-import failed; see above.
I can't find anything on this error at all. Can anyone help?
I stopped the bitbucket service and tried again. Same response. I started bitbucket and it wouldn't start up. However, since everything is virtual and we had taken a snapshot first, we could roll back without any harm. But it still leaves the original question of how to run git-filter-repo
(or in some other way clean up the history) on the server.
There is an alternative. I can, I think:
- Create a mirror clone
- Use
git-filter-repo
to remove the file - Delete the repo on Bitbucket server
- Create a new empty with the same name on the server
- Push from our cleaned-up copy up to the server
This cleans up the repo size (which is my main concern - given our CI process clones this repo so much, having it very bloated will be an issue) and I have the history and branches and tags as far as I can see. What I lose is the settings and the history of pull requests, etc. I'd like to keep those if I can - it's really useful to be able to go to an issue in Jira and click the link to even a closed PR and see from the diff exactly what was done. But if I have to choose between fixing the repo size and keeping old PRs then I'll fix the repo size.