GIT-COMMIT-TREE(1)
π git-commit-tree(1) β the Git Manual, bestie edition π
okay so real talk: this is a page from the Git Manual and it's all about git-commit-tree, the lowkey little gremlin that actually makes commit objects. buckle up π
β¨ NAME β¨
git-commit-tree β create a new commit object πΈ
β¨ SYNOPSIS β¨
git commit-tree <tree> [(-p <parent>)...]
git commit-tree [(-p <parent>)...] [-S[<keyid>]] [(-m <message>)...]
[(-F <file>)...] <tree>
β¨ DESCRIPTION β¨
bestie, listen π this is usually not what an end user wants to run directly. like, respectfully, go look at git-commit(1) instead, that's the one you actually want. but if you're here on purpose? respect. π«Ά
What it does: it creates a new commit object based on the tree object you hand it, and then it emits the new commit object id on stdout. the log message gets read from standard input β unless you gave it -m or -F options, in which case it uses those instead. no cap.
The -m and -F options can be given any number of times, in any order, and the commit log message will be composed in the order in which the options are given. yes, order matters, the way that it does π
A commit object may have any number of parents. with exactly one parent it's just an ordinary commit. having more than one parent makes the commit a merge between several lines of history. and initial (root) commits have no parents at all β they're the main character, born with nothing π
While a tree represents a particular directory state of a working directory, a commit represents that state in "time", and explains how to get there. it's giving time capsule π¦
Normally a commit would identify a new "HEAD" state, and while Git doesn't care where you save the note about that state, in practice we tend to just write the result to the file that is pointed at by .git/HEAD, so that we can always see what the last committed state was. iconic behavior fr fr.
β¨ OPTIONS β¨
<tree>β an existing tree object. like, it has to already exist, don't come at me with a fake one π-p <parent>β each-pindicates the id of a parent commit object. stack 'em up if you're making a merge π-m <message>β a paragraph in the commit log message. this can be given more than once, and each<message>becomes its own paragraph. one paragraph per-m, slay.-F <file>β read the commit log message from the given file. use-to read from the standard input. this can be given more than once, and the content of each file becomes its own paragraph. very demure, very organized π-S[<keyid>],--gpg-sign[=<keyid>],--no-gpg-signβ GPG-sign commits. thekeyidargument is optional and defaults to the committer identity; if you specify it, it must be stuck to the option without a space (no space, bestie, i mean it).--no-gpg-signis useful to countermand a--gpg-signoption given earlier on the command line β like an undo button for your signature vibes π₯
β¨ COMMIT INFORMATION β¨
A commit encapsulates:
- all parent object ids
- author name, email and date
- committer name and email and the commit time.
A commit comment is read from stdin. if a changelog entry is not provided via "<" redirection, git commit-tree will just wait for one to be entered and terminated with Ctrl+D. it's literally just sitting there, waiting for you, patiently π
β¨ DATE FORMATS β¨
The GIT_AUTHOR_DATE and GIT_COMMITTER_DATE environment variables support the following date formats:
Git internal format π
It is <unix-timestamp> <time-zone-offset>, where <unix-timestamp> is the number of seconds since the UNIX epoch. <time-zone-offset> is a positive or negative offset from UTC. for example CET (which is 1 hour ahead of UTC) is +0100.
It is safer to prepend the <unix-timestamp> with @ (e.g., @0 +0000), which forces Git to interpret it as a raw timestamp. this is required for values less than 100,000,000 (which have fewer than 9 digits) to avoid confusion with other date formats like YYYYMMDD. so like, don't skip the @, please, it's there for a reason π
RFC 2822 π
The standard date format as described by RFC 2822, for example Thu, 07 Apr 2005 22:13:13 +0200.
ISO 8601 β
Time and date specified by the ISO 8601 standard, for example 2005-04-07T22:13:13. the parser accepts a space instead of the T character as well. fractional parts of a second will be ignored β for example 2005-04-07T22:13:13.019 will be treated as 2005-04-07T22:13:13. bye bye milliseconds π
Note π§ In addition, the date part is accepted in the following formats:YYYY.MM.DD,MM/DD/YYYYandDD.MM.YYYY. (yes, three different ones, chaos is the point π)
β¨ DISCUSSION β¨
Git is to some extent character encoding agnostic. like it really said "encoding? never heard of her" but also "i have opinions" πΈ
- The contents of the blob objects are uninterpreted sequences of bytes. there is no encoding translation at the core level. raw bytes, no notes.
- Path names are encoded in UTF-8 normalization form C. this applies to tree objects, the index file, ref names, as well as path names in command line arguments, environment variables and config files (
.git/config(seegit-config(1)),gitignore(5),gitattributes(5)andgitmodules(5)).
Note that Git at the core level treats path names simply as sequences of non-NUL bytes, there are no path name encoding conversions (except on Mac and Windows). therefore, using non-ASCII path names will mostly work even on platforms and file systems that use legacy extended ASCII encodings. however, repositories created on such systems will not work properly on UTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa. additionally, many Git-based tools simply assume path names to be UTF-8 and will fail to display other encodings correctly. so like... be aware π¬
- Commit log messages are typically encoded in UTF-8, but other extended ASCII encodings are also supported. this includes
ISO-8859-x,CP125xand many others, but not UTF-16/32, EBCDIC and CJK multi-byte encodings (GBK,Shift-JIS,Big5,EUC-x,CP9xxetc.). those ones are not invited to the party π«
Although we encourage that the commit log messages are encoded in UTF-8, both the core and Git Porcelain are designed not to force UTF-8 on projects. if all participants of a particular project find it more convenient to use legacy encodings, Git does not forbid it. however, there are a few things to keep in mind. π
git commitandgit commit-treeissue a warning if the commit log message given to it does not look like a valid UTF-8 string, unless you explicitly say your project uses a legacy encoding. the way to say this is to havei18n.commitEncodingin.git/configfile, like this:
[i18n]
commitEncoding = ISO-8859-1
Commit objects created with the above setting record the value of i18n.commitEncoding in their encoding header. this is to help other people who look at them later. lack of this header implies that the commit log message is encoded in UTF-8. thoughtful queen behavior π
git log,git show,git blameand friends look at the encoding header of a commit object, and try to re-code the log message into UTF-8 unless otherwise specified. you can specify the desired output encoding withi18n.logOutputEncodingin.git/configfile, like this:
[i18n]
logOutputEncoding = ISO-8859-1
If you do not have this configuration variable, the value of i18n.commitEncoding is used instead. fallback vibes β¨
Note that we deliberately chose not to re-code the commit log message when a commit is made to force UTF-8 at the commit object level, because re-coding to UTF-8 is not necessarily a reversible operation. and irreversible stuff? not on their watch π
β¨ FILES β¨
/etc/mailname
(that's it. that's the file. one single file. she's alone but she's thriving π)
β¨ SEE ALSO β¨
git-write-tree(1) git-commit(1)
β¨ GIT β¨
Part of the git(1) suite π«Ά
and that's the whole page, bestie!! this was Git 2.56.0, dated 2026-09-27, brought to you by the GIT-COMMIT-TREE(1) girlies π go make some commits the hard way, i believe in you β¨π
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms