I wrote the blog couple days ago – BitBucket Server Unreachable When Merge Pull Request, as mentioned the issue was caused by the big size of the repository. As a workaround/ quick fix, we increased the merge timeout value, and upgraded Git to a newer version which remediate the issue.
The issue will come back if the repository size keeps growing. The proper way to fix the issue permanently is to reduce the size by using Git LFS and BFG. Here are the steps that I would suggest to try:
- Clone the bare repository and make a copy of it as a backup. In the sample it is big-repo.git
git clone --mirror ssh://git@bitbucket/myproject/big-repo.git
- Convert big files into lfs. In the sample, I would like to convert any zip, jar, war files to git lfs. Please be aware it will rewrite the history, e.g the commit ID will change.
java -jar bfg.jar --convert-to-git-lfs "*.{zip,jar,war}" --no-blob-protection big-repo.git
- Create a new repository on Bitbucket and enable Git LFS. In the sample, I just call it new-repo.git
- Add the new repo to your local git remote, and name it as newrepo.
git remote add newrepo ssh://git@bitbucket/myproject/new-repo.git
- Verify the above remote settings.
git remote -v
- Push your local repository to the new repository.
git push newrepo --all
- Clone the new repo to your local.
git clone ssh://git@bitbucket/myproject/new-repo.git
- Track all zip, jar, war file in the new repo.
cd new-repo
git lfs install
git lfs track "*.zip" "*.jar" "*.war" - Make sure you .gitattributes is tracked by git.
git add .gitattributes
git commit -m "track lfs file types"
git push - Notify each person in your team to install git lfs. Then clone and start to use the new-repo which is lfs-enabled.
Reference:
https://confluence.atlassian.com/bitbucket/use-bfg-to-migrate-a-repo-to-git-lfs-834233484.html
https://git-lfs.github.com/