User Tools

Site Tools


Inspecting Git repository

The Three Main States

State Location Description Method of inspection
Commited .git directory Stored in DB git log git show
Modified Working directory Changed git status git diff
Staged Staging area (.git/index) Changed and marked for next commit to the DB git status

Staging area has many names:

  • Index
  • Cache
  • Directory cache
  • Current directory cache
  • Staging area
  • Staged files


There are many ways to distinguish a specific commit from Git repository.

  1. SHA (hash) - The SHA-1 algorithm is used to create a unique 40-byte hexadecimal string in many corners of git. The SHA (hash-object cat-file)
  2. (refnames, refs)
    1. Branch reference (heads) - Branches in Git are nothing more than pointers to the commit. Branch reference is a SHA value of the most recent commit and it is updated with each new commit added. (show rev-parse show-ref)
    2. Tag reference - Similar to Branch reference but does not change with new commits. (git describe)
    3. HEAD (@) - Note the capital letters. Points to the current commit. (git describe)
    5. <refname>@{<date>} - For example master@{yesterday}, HEAD@{5 minutes ago}. Note: Date parsing is undocumented but the parser code can be accessed on github.
    6. <refname>@{n} - For example master@{7} returns 7th prior commit from master head.
    7. <refname>@{-n} - For example @{-2} returns 2nd commit checked out before current one.
    8. <branchname>@{upstream} git rev-parse –symbolic-full-name @{u}
    9. <rev>^n
    10. <rev>~n
    11. more …

Walking the tree with ''^'' and ''~''

A =      = A^0
B = A^   = A^1     = A~1
C = A^2  = A^2
D = A^^  = A^1^1   = A~2
E = B^2  = A^^2
F = B^3  = A^^3
G = A^^^ = A^1^1^1 = A~3
H = D^2  = B^^2    = A^^^2  = A~2^2
I = F^   = B^3^    = A^^3^
J = F^2  = B^3^2   = A^^3^2


(idea taken from here)

<html> <?xml version=“1.0” encoding=“UTF-8” standalone=“no”?>



  1. <rev> - ancestors of commit revision
  2. ^<rev>
  3. <rev1>..<rev2> - reachable from rev2 but exclude reachable from rev1 (none is HEAD)
  4. <rev1>…<rev2> - reachable from either but not both (none is HEAD)
  5. more …


“Log of references” - list of updates to the references

git reflog


Show difference between working directory (or index if –cached) and commited.


Debugging with Git

blame Line-by-line who last modified line
grep Search files for given expression
bisect Manually switch between commits until the one that introduces a chenge is found


projects/progit/inspection.txt · Last modified: 2016/02/21 21:28 by mkucia