How to free up space in the .git folder?

Solution 1:

then I realized there is a hidden .git folder which size is 80Gb

If your .git folder is that big and that you are doing Unity development, I really hope that you are using git-lfs.

Otherwise you did a big mistake and you will have to fix that (and it's much more complicated if you don't have free space anymore so I won't answer here)

If you are using git-lfs, you can cleanup objects not used anymore with the command: git lfs prune

Only after that and if it made some free spaces, then you could do a git gc

So I went to Git GUI and pressed on compressed and it consumed all of my free space in my disk, the command didn't even finished.

If it behave like that and failed to compress the git object, that probably means that you didn't enabled git-lfs and so git has difficulties to compress your big binaries assets so you will have to enable it and convert your whole git history to use it. But before ensure that the git hosting you are using is supporting it...

For your migration, things like that could help:

  • https://docs.gitlab.com/ee/topics/git/lfs/migrate_to_git_lfs.html
  • https://notiz.dev/blog/migrate-git-repo-to-git-lfs

And I'm not sure it could be done when your disk is full. So maybe you will have to make free space or copy your repository elsewhere and do the work from there (it still a good idea to do a copy as a backup before starting to do these things).

Buy an external hard drive if needed...

Unity with Git: https://thoughtbot.com/blog/how-to-git-with-unity