简体   繁体   English

git存储库可以处理的提交数量是否有上限?

[英]Is there an upper limit to the number of commits a git repository can handle?

I'm wondering if there's an upper limit to the number of commits that a git repository can handle. 我想知道git存储库可以处理的提交数量是否有上限。

In a solo project I'm working on right now, I've been coding locally, committing/pushing changes in git, then pulling the changes on my development server. 在我正在进行的一个独立项目中,我一直在本地编写代码,提交/推送git中的更改,然后在我的开发服务器上进行更改。

I treat this as an easier alternative to working locally and uploading changes via FTP... Fortunately/Unfortunately it's such an easy workflow that I sometimes go through many edit/commit/push/pull/browser-refresh cycles while coding. 我认为这是在本地工作和通过FTP上传更改的更简单的替代方案...幸运/遗憾的是,这是一个如此简单的工作流程,我有时会在编码时经历许多编辑/提交/推/拉/浏览器刷新周期。

I'm wondering if this is going to turn around and bite me somewhere down the line. 我想知道这是否会转过来让我陷入困境。 If it's likely to be a problem, I'm wondering how I can avoid that trouble ... It seems like a rebase might be the way to go, especially since I won't have to worry about conflicting branches etc. 如果它可能是一个问题,我想知道如何避免这种麻烦...看起来像一个rebase可能是要走的路,特别是因为我不必担心冲突的分支等。

Well the "upper limit" would likely be the point at which a SHA1 collision occurs, but since the SHAs are 40 hexadecimal digits long (16^40 ~ 1.4x10^48 possibilities), it's so close to zero possibility that it's not even funny. 那么“上限”可能是发生SHA1碰撞的点,但由于SHA是40个十六进制数字长(16 ^ 40~1.4x10 ^ 48种可能性),所以它几乎没有可能性甚至不好笑。 So there's roughly a zero percent chance you'll have any problems for at least the next several millennia. 因此,至少在接下来的几千年里,你几乎有百分之百的机会遇到任何问题。

Hyperbolic Example (just for fun): 1 commit/minute (just changing one file -> three new SHAs used (file, commit, tree) = 3 new shas used / minute = ... = 1.6M shas used / year = 1.6 Billion shahs / millennia = 1x10^-37 % used each millenia... (at 1000 files/commmit/min, it's still 3.6x10^-35%) 双曲线示例(只是为了好玩):1次提交/分钟(只更改一个文件 - >使用三个新的SHA(文件,提交,树)= 3个新shas使用/分钟= ... = 1.6M shas used / year = 1.6亿万/千年= 1x10 ^ -37 使用每个千年......(1000档/每分钟/分钟,它仍然是3.6x10 ^ -35%)

That being said, if you want to clean up your history, squashing them down with rebase is probably your best bet. 话虽如此,如果你想要清理你的历史,用rebase压扁它们可能是你最好的选择。 Just make sure you understand the implications if you've shared the repo publicly at all. 如果您公开分享回购,请确保您了解其含义。

You might also want to garbage collect after rebasing to free up some space (make sure the rebase worked right first, though, and you might need to tell it to collect everything or it will, by default, not collect anything newer than two-weeks old). 您可能还希望在重新定位后进行垃圾收集以释放一些空间(确保首先使用rebase工作正常,并且您可能需要告诉它收集所有内容,否则默认情况下不会收集任何超过两周的内容旧)。

I'm pretty sure you don't have to worry at all :) 我很确定你根本不必担心:)

Git is using SHA-1 hash in order to check files, the probability of having an hash conflict is near zero. Git使用SHA-1哈希来检查文件,哈希冲突的概率接近于零。 So have fun !! 所以玩得开心!!

I personally did around 30 commits a day without issue. 我个人每天做大约30次提交没有问题。

But avoid versioning binaries files :) it's really heavy for what it is. 但是避免版本化二进制文件:)它真的很重要。

I think there is no strong limit to the number of commits git can handle, only what you can personally digest. 我认为git可以处理的提交数量没有很大的限制,只有你可以个人消化的数量。 With larger projects and multiple developers, you'll see more activity than you would ever generate on your own. 对于较大的项目和多个开发人员,您将看到比您自己生成的更多活动。

You can keep a secondary branch that you merge to every week if you wish, but git will never care about how many commits you have. 如果您愿意,您可以保留每周合并的辅助分支,但git永远不会关心您拥有多少提交。 Go crazy as long as you can understand what you're doing. 只要你能理解你在做什么,就去疯狂。 You can always diff several commits back or use tools like bisect to figure out history problems. 你总是可以将几个提交分开,或者使用像bisect这样的工具来找出历史问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM