Wednesday, November 11, 2009

git date spec, ordinal spec, carrot parent, tilde spec

Date Spec

The Ref Log that git keeps will allow you to do some relative stuff locally, such as:


master@{1 month ago}

Which is shorthand for 'where the master branch head was yesterday', etc. Note that this format can result in different shas on different computers, even if the master branch is currently pointing to the same place.

Ordinal Spec

This format will give you the Nth previous value of a particular reference. For example:


will give you the 5th prior value of the master head ref.

Carrot Parent

This will give you the Nth parent of a particular commit. This format is only useful on merge commits - commit objects that have more than one direct parent.


Tilde Spec

The tilde spec will give you the Nth grandparent of a commit object. For example,


will give us the first parent of the first parent of the commit that master points to. It is equivalent to:


You can keep doing this, too. The following specs will point to the same commit:


No comments: