git 最大提交消息大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9733757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:36:24  来源:igfitidea点击:

Maximum commit message size

git

提问by Juraj Martinka

Is there any size limit to the Git commit message? I searched trough the web but cannot find any relevant mention about this except this one.

Git 提交消息有大小限制吗?我在网上搜索过,但除了这个之外找不到任何相关的提及。

However, that one does not answer my question.

然而,那个人并没有回答我的问题。

采纳答案by Amber

https://github.com/git/git/blob/master/strbuf.hdefines the lenfield to be a size_t. So at the very least, the maximum length has an upper bound at the maximum value of size_ton your platform of choice.

https://github.com/git/git/blob/master/strbuf.h将该len字段定义为size_t. 因此,至少,最大长度的上限为size_t您选择的平台上的最大值。

回答by huon

Empirically, I think the answer is no. This worked (that's a ~100MB commit message):

根据经验,我认为答案是否定的。这有效(这是一个 ~100MB 的提交消息):

yes | head -c 100000000 | git commit -F - > /dev/null

Command parts explanation:

命令部分说明:

  • yesrepeats "y\n" forever
  • head -c 100000000takes only the first 100,000,000 bytes (~100MB)
  • git commit -F -commits with the passed-in commit message (this won't work if you haven't staged any changes to commit)
  • > /dev/nullhides the output from the command, which includes Git repeating back the very long commit message
  • yes\n永远重复“y ”
  • head -c 100000000只占用前 100,000,000 字节 (~100MB)
  • git commit -F -使用传入的提交消息提交(如果您没有提交任何更改,这将不起作用)
  • > /dev/null隐藏命令的输出,其中包括 Git 重复很长的提交消息

回答by Doug Robinson

Well, actually, there is a limit of ~5MB for JGit.

嗯,实际上,JGit 有大约 5MB 的限制。

Of course, I've got to ask why anyone would do that?! Especially since every subsequent clone would need to include that data. I'd say that if you're going beyond a few KB then you really should be questioning your motives.

当然,我必须问为什么有人会这样做?!特别是因为每个后续克隆都需要包含该数据。我想说的是,如果你超出了几个 KB,那么你真的应该质疑你的动机。