My repository is too big for BitBucket (~500 MB), I've decided to move it to GitLab. After copying it to GitLab, I've tried to clear the existing BitBucket repository. I don't want to remove it completely, I want to remove all files/history with adding a little README with information about moving to the new address (GitLab).
To to this, I used the following commands:
git init (in a new folder)
git remote add origin https://bitbucket.org/(my_repository)
git add ... (my readme file)
git push --force origin master
After this, I don't see any information in the log. But the size of my repository in BitBucket web interface is still ~500 MB, and attempt to clone it creates a very large .git folder
What is the reason? How to REALLY decrease the size of an already unnecessary repository?
At the same time, BFG utility can reduce the size of .git folder, at least in my local copy. But this utility is focused on another problem - removing very large files or some selected file. My problem is more simple: I just want to remove all, without removing the repository itself. How to do this?
Welcome to the community.
I've run Git GC (Garbage Collection) against your repository.
It is now down to 450 MB.
Could you check the same on your end?
Regards,
Mark C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much! It means that I did something wrong, though I consulted here and with ChatGPT. I want to completely remove all my files and history. I already created a new clean repository via git init and also deleted the old branch as Ignacio Ampuero advised. However, the repository size is still 450 MB. What is the reason?
Is there any way to delete all previous commits without full deletion of the repository via BitBucket web interface?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Perhaps you can you can reset your commits to the first initial commit you've made in the repository. - https://www.atlassian.com/git/tutorials/undoing-changes/git-reset
However, please note that this option is likely going to remove commits history, hence, I suggest taking a backup of your repository locally before proceeding.
Regards,
Mark C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your advice with git reset.
I've checked my repository again and found that there was a very old branch with almost a complete copy of my content. I've switched to that branch and performed git reset, then
git push --force
Now git gc on my computer reduces the size to a few megabytes. Could you also call git gc again on the server side?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've gone ahead and run Git GC, the repository size is now 13.8 MB (450.9 MB).
Regards,
Mark C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey!
The way git works is maintaining a history of changes of your repo.
So with your last "empty folder push" you just added a whole repo change from full repo to empty repo, but still just a change, so all the history and repo size is tracked by git.
So what you need to do is the following:
git checkout --orphan new_branch
git rm -rf .
vim/nano/whatever_editor README.md
git add README.md
git commit -m "Repository moved to GitLab"
git branch -D master/main/production (choose the name depending of your main branch)
git branch -m new_branch master/main/production (depending on your case)
git push --force origin main
That's all the process, it seems long but it has sense because of the way git works and tracks stuff.
Good luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This does not help. The size of repository, shown by BitBucket web interface, is still 634 MB, and attempt to clone it creates .git folder ~450 MB
All that I need is to CLEAR all the history and all files. But I don't want to remove the repository permanently, via BitBucket web interface. Maybe some other user will try to pull, and he will have no any hints why this repository is not available and where it is now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In fact
That procedure should have done that
But if you see an empty main branch (with just the README) and cloning generates a heavy .git history. Then the fault is not yours.
There are some cases that repos need manual Garbage Collection, as seen on this discarded feature request
[BCLOUD-11593] Allow users to mark repositories for git gc (BB-13894) - Create and track feature requests for Atlassian products.
But there's also the manual request you can ask to the attlassian team over your repo via request to:
https://support.atlassian.com/contact/.
So they can clean all the dangling objects on your repo's history.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've started from https://support.atlassian.com/contact/
But the only available option for my free account was asking the question here :)
You think that I need just to wait until the automatic git gc will run? If so, why manual calling "git gc" on my local repository does not reduce the size of .git folder?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, I see
Yes, bitbucket documentation states that they run GC periodically, but depending on repo size and other factors.
For some users sometimes atlassian team goes in and runs GC, via the community forum posts.
You can try with some strict pruning with:
git reflog expire --expire=now --all
git gc --prune=now --aggressive
for local .git folder cleaning.
And to try a light clone you can use:
git clone --depth=1 bitbucket.com/your_repo
so it doesn't pull the lingering history of the bitbucket server.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.