git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how the commit ID come from in GIT?

From
MBMagnus Bäck <baeck@google.com>
Date
Nov 5, 2012, 20:26 UTC
Message-ID
<20121105202621.GA31625@google.com>
In-Reply-To
<1352145846.26267.YahooMailClassic@web141404.mail.bf1.yahoo.com>
On Monday, November 05, 2012 at 15:04 EST,
     hong zhang <henryzhang62@yahoo.com> wrote:
> Could anyone explain how the git commit ID will include all the files
> that devloper makes changes on?
>
> How git commit ID works?

In short, a Git commit points to a tree object that describes the full state of the source tree plus metadata like the commit author, date, description, and a pointer to the commit object(s) that preceded the commit. The commit id itself is the SHA-1 of the contents of the commit object. Any change of the source tree will affect the top-level tree object's SHA-1 which in turn affects the SHA-1 of the commit. Also, because a commit contains the timestamp of the commit object's creation even two commits that are content-wise identical will have different SHA-1s.

If you haven't read it, the Pro Git books explains Git's object model in detail: http://git-scm.com/book/en/Git-Internals-Git-Objects

That description is quite detailed, and most users don't need to go that deep.

-- 
Magnus Bäck
baeck@google.com
Previous: hong zhangNext: Konstantin Khomoutov
Message 2 of 3 in “how the commit ID come from in GIT?”
  1. hong zhangNov 5, 2012
  2. Magnus BäckNov 5, 2012
  3. Konstantin KhomoutovNov 5, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.