Treeish

Treeish

A Treeish is just a way for us to reference a commit in the git tree in a convient way. These treeish allows us to reference a parent commit with having to know its commit hash id.
Example Usage:
#get the parent commit of the current head
git checkout HEAD^
#get the grand parent commit of the current head
git checkout HEAD^^

Parent Commit

  1. HEAD^          - References the parent of the current HEADd
  2. ab23cda32^   -References the parent of the commit with the given ID
  3. master^          -Refrences the parent the given branches head

Grand Parent Commit

  1. HEAD^^          - References the grand parent of the current HEADd
  2. ab23cda32^^   -References the grand parent of the commit with the given ID
  3. master^^          -Refrences the grand parent the given branches head

Great Grand Parent Commit

  1. HEAD^^^          - References the greate grand parent of the current HEAD
  2. ab23cda32^^^   -References the great grand parent of the commit with the given ID
  3. master^^^          -Refrences the great grand parent the given branches head

Alternatively we can also use the tilde character

Parent Commit

  1. HEAD~          - References the parent of the current HEAD

Grand Parent Commit

  1. HEAD~1          - References the grand parent of the current HEAD

Great Grand Parent Commit

  1. HEAD~2         - References the greate grand parent of the current HEAD
Cookbook Category: 
Git

Add new comment