A list of object types and good diagram showing their relationships
can be found in this SO answer. (This discusses only
objects and should be supplemented with the information in
ref
.)
Object can be displayed with git cat-file TYPE OBJECT
. Batch output
options are also available. The following options omit the type:
-t
: show object type (blob
,tree
,commit
,tag
, …)-p
: pretty-print.-e
: check for existence.
<ref>
: A "branch" name (mutable pointer) in the local repo. Stored under.git/refs/…
.<object>
The name (SHA1) of any type of object<blob>
,<tree>
,<commit>
: The name of a specific type of object<type>
: one of the git object types: blob, tree, commit, tag<file>
: file path usu. relative to tree described by GIT_INDEX_FILE
<commit-ish>
and <tree-ish>
are taken by commands that eventually
want to operate on a particular <commit> or <tree>; tags, refs,
<commit>s will be deferenced until reaching one.
The gitrevisions(1)
manpage has full details of ways to specify
revisions, ranges of revisions and trees. Chapter 7.1 Revision
Selection in Pro Git offers a useful tutorial. A short
table summarizing some (not all) of this is in this SO
answer. These include:
Commit-ish/Tree-ish:
- SHA1 of commit (or tree).
- Output of
git describe
. - Using
@...
forHEAD
orrefname@...
:@{date}
where date isyesterday
,2 days 3 minutes ago
,2018-03-11 13:22:17
, etc.@{upstream}
,@{u}
: upstream of given branch.@{push}
: local tracking ref of the remote ref to which we'd push if the given ref was checked out. Different from{upstream}
when we're pushing to a different place whence we pull.@{n}
: nth previous value of given ref (0
= current) from reflog.
@{-n}
(no refname before@
): nth branch/commit checked out before the current one.rev~
,rev~n
: nth generation ancestor, following first parents (^1
)rev^
,rev^n
: select nth direct parent (default 1) of given commit. Parent0
is the commit itself rather than a parent.- May be repeated, e.g.,
rev^^2^1
. - Append
{commit}
,{tag}
or{tree}
to select that object type. - Append
{}
to dereference recursively until non-tag is found. - Append
{/regexp}
to match commit with regexp in commit message.
- May be repeated, e.g.,
:/regexp
: Youngest commit reachable from any ref with message matching regexp.
a..b
gives all commits that are part of b and not part of a.
E.g., master..dev
gives all commits on branch dev that are not on
branch master.
a...b
gives all commits that are a part of either a or b but not
both. Probably you want to use --graph
with multiline output when
these are separate branches.