Maximum commit message size
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.
However, that one does not answer my question.
- Combining SVN and Git
- git command to get all branches I've merged into develop since a given date?
- Git local mirror and repository
- Best practice to deploy python app to use a specific version of Python with venv
- moving committed (but not pushed) changes to a new branch
- Broken links and layout after referring custom domain to jekyll-generated github project page
2 Solutions collect form web for “Maximum commit message size”
https://github.com/git/git/blob/master/strbuf.h defines the
len field to be a
size_t. So at the very least, the maximum length has an upper bound at the maximum value of
size_t on your platform of choice.
Empirically, I think the answer is no. This worked (that’s a ~100MB commit message):
yes | head -c 100000000 | git commit -F - > /dev/null
Command parts explanation:
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