I have a git project but the problem is that the directory ".git" is too big. Indeed, my whole project is 3MB but the ".git" is 36MB. Why is it so big? How can I clean it?
I have a git project but the problem is that the directory ".git" is too big. Indeed, my whole project is 3MB but the ".git" is 36MB. Why is it so big? How can I clean it?
Remember that every time you do a commit, every changed file in the commit takes up space in the repository. Even if the change itself is just one letter, the whole file is there, at least twice (before the change and after the change). The entire history, the state of every file in every commit, even if that file doesn't visibly "exist" any more at the end of the branch where you are working, is in the repo!
Let's say you have a 1MB jpg image and you change it 36 times and commit each time. Bingo, that's (at least) 36MB in the repo. And if you now delete that jpg image and commit, the repo won't get any smaller because of that.
I use jpg as my example on purpose; usually it is binaries that take up a lot of space. Git can save some space with regard to text files, but it can't do that with binaries.
Having said that, however, I should also say: 36MB is not big. It's pretty big, but it's not atypical of how big a repository can be for a large project with a long history.