Git/commit

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Git
Jump to navigation Jump to search

Concept

"A commit" is a specific set of project-file revisions that are archived together at a specific time. A commit is created from what is currently in the staging area.

"Committed" seems to be a per-file flag that indicates whether a staged file is ready for further operations, such as pushing.

At commit time, Git checksums each subdirectory (and file?) and stores those tree objects under the HEAD branch of the project's Git repository (which is kept under the .git/ folder). Git then creates a commit object that has the metadata and a pointer to the root project tree so it can re-create that snapshot when needed.

When you create a commit with git commit, Git stores the following objects:

  • one blob for each of your files, containing that file's contents
  • one tree that lists the contents of the directory and specifies which file names are stored as which blobs
  • a commit object, which is basically a pointer to the snapshot of the content you staged, which contains:
    • the author's name and email (from Git's configuration data)
    • the commit message that you typed when creating the commit
    • pointers to the commit or commits that directly came before this commit (its parent or parents)
      • zero parents for the initial commit
      • one parent for a normal commit
      • multiple parents for a commit that results from a merge of two or more branches.

The last two paragraphs were adapted from 3.1 Git Branching - Branches in a Nutshell.

Related

  • git log returns information about existing commits

Command

Reference