Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 2.2 KB

commit.md

File metadata and controls

67 lines (46 loc) · 2.2 KB

Git Commits

For some tips on fixing/rewriting commits, see Git Tips.

Plumbing

The plumbing command to create a git commit is git commit-tree:

git commit-tree <tree> [(-p <parent>)...] \
    [-S[<keyid>]] [(-m <message>)...] [(-F <file>)...]

Multiple -m arguments specify an ordered list of paragraphs in the commit message. Stdin is used if -mF are not given or they result in an empty message. (Use </dev/null) to get an empty message.)

Author and committer name/date information is taken in order from $GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL,DATE}, user.{name,email} and $EMAIL. <, > and \n are stripped. Dates are formatted as @<unix-timestamp> <tzoffset>, ISO-8601 or similar.

Show a raw commit with git cat-file -p REF.

git write-tree creates a tree from an index. The index must be in a fully merged state.

Stash Commits

git stash stores its data as commits marked with the refs/stash ref; multiple stashes are found through the reflog of refs/stash, e.g.:

$ stash list
stash@{0}: WIP on master: d569aec two
stash@{1}: On master: stash2

The stash consists of several commits 2-3 of which are new:

  1. head: The current HEAD commit when you stashed (pre-existing).
  2. untracked: Optional; an orphan (parentless) commit containing a tree of all untracked files at the time of the stash. This is created only with the -u (untracked files) or -a (all files, untracked and ignored) options.
  3. index: the staged commits (in the index) at the time of stash, with parents head and, if present, untracked.
  4. wc: The working copy's tracked but unstaged files at the time you stashed, with parents head and index.

Diagram:

       .----W----.
      /    /    /
-----H----I    U

See also more details on the stash algorithms.