Why git operations becomes slow when repo gets bigger

六眼飞鱼酱① 提交于 2020-01-24 11:53:29

问题


I know git would get slow when the repo get bigger.
But why?
As git stores files as separate directories and files under .git, i can not find out why the operations get slowwer. Let's have a look at the commit operation. Recently, i cloned the webkit repo and i branch from master, then i commit a 2k file to the branch. But i feel it gets slowwer than that i do on my small repo.
Because i have not read through git source code, i guess the commit operation compromises storing the file to the disk, inserting the commit log, updating the index and updating the HEAD to the sha value of the file.

The write is fast.
The inserting is fast.(I guess, if the insert action is append log to a file)
The updating index is fast.
The updating HEAD is fast.

And why it is slow? Can anyone illustrate it to me?
Thanks.

Some answers is helpful but not very convincible, it will be great to provide some code snippets to support you.


回答1:


Committing a tree should be constant in time, since it only needs to create a new commit object (git write-tree) and update the HEAD ref.

I did benchmarks of different SCMs in the past and git commit was indeed not affected by tree size, repository size, history length, etc.



来源:https://stackoverflow.com/questions/17543379/why-git-operations-becomes-slow-when-repo-gets-bigger

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