How much space do I need for Git vs SVN?

北城余情 提交于 2019-12-01 14:36:56

问题


We are currently using Subversion as our source code repository. We are in the planning phase of converting to Git. Our Subversion repository is currently 19Gb. How does a Git repository compare to Subversion on disk space requirements? What will my 19Gb svn repository translate to in a Git repository.


回答1:


It's hard to guess the exact size that your Git repository will take because it depends on several factors, for instance

  • type of stored objects
  • number of branches, tags
  • number of similar/duplicate objects

Git has a good compression algorithm and, from my past experience, it was able to reduce the size of a SVN repository up to 10 times. Here's some examples.

However, the best way is to try it yourself. On your local machine you can convert the SVN repository into Git

$ git-svn clone -s http://path/to/subversion reponame

then run git gc and see how much space you need to start.




回答2:


As git keeps the whole repo on each machine, it also stores the full history and if you have added and then deleted a large file, you will notice that actually the disk space hasn't been decreased. If you are completely sure you want to permanently delete file, you need to run special commands in git.

git filter-branch -f --index-filter 'git rm -r --cached --ignore-unmatch "filename"' --prune-empty HEAD
rm -rf .git/refs/original/ && git reflog expire --expire=now --all && git gc --aggressive --prune=now

Today I moved one of my svn repos to git using the git svn command, which allows you to move not only current data but also history. And here is what I've got.

The current svn repo size on my pc is 1.27 GB, the newly created git repo is 3.24 GB. This is because git repo contains the whole history, the deleted files are not actually deleted in git, until you do it explicitly like I mentioned above. If you find any problems while moving to git you may look for answers here



来源:https://stackoverflow.com/questions/7727791/how-much-space-do-i-need-for-git-vs-svn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!