Glossary

Commit/Tree-ish

Commit-ish Resolves to
HEAD F (the branch HEAD is currently pointing to)
HEAD^ = HEAD^1 = HEAD~ = HEAD~1 B (HEAD’s first parent)
F^2 C (F’s second parent)
D~~ = D~2 = D^^ A (2 past generation first ancestor)
refs/head/master = head/master = master F (master branch tip)
HEAD@{1 days ago} B (yesterday you were working on the topic branch)
:/commit\_msg The youngest matching command from ANY ref commit matching message

Revision ranges

        A---B---C topic
       /
  D---E---F---G master
Revision range Resolves to
B D, E, A, B (all commits reachable from B)
B^@ D, E, A (all commits reachable from B, except himself)
C G ALL (commits reachable from both C and G)
G ^C = C..G (double dot) G, F (commits reachable by G and NOT by C)
C...G (triple dot) C, B, A, F, G (commits reachable by C or G but NOT both)

Reset and checkout

      A---B---C topic                                     A---B---C topic <- HEAD                          A---B---C topic
     /                        (git checkout topic)       /                         (git checkout F)       / 
D---E---F---G master <- HEAD                        D---E---F---G master                             D---E---F---G master
                                                                                                             ^
                                                                                                           HEAD (detached mode)


      A---B---C topic                                     A---B---C topic <- master <- HEAD 
     /                        (git reset topic)          /                        
D---E---F---G master <- HEAD                        D---E---F---G <- Orphan branch (may be cleaned on garbage collection)
Reset/Checkout command Branch ref Index Working directory
git reset --soft <commit-ish> <commit-ish> NO change NO change
git reset --mixed <commit-ish> <commit-ish> <commit-ish> NO change
git reset --hard <commit-ish> <commit-ish> <commit-ish> <commit-ish>
git reset --mixed <path> (cannot accept a commit-ish) N/A <commit-ish> NO change
git reset --hard <path> (cannot accept a commit-ish) N/A <commit-ish> <commit-ish>
git checkout <commit-ish> (like reset hard with exceptions) <commit-ish> <commit-ish> <commit-ish>
git checkout <commit-ish> <path> NO change NO change (unless path is staged) reverts <path> to <commit-ish>

.git directory

Rebasing branches

        F---G topic <- HEAD                                    D---E branch
       /                                                      / 
      D---E branch                (git rebase master)        /   D'---F'---G' topic <- HEAD
     /                                                      /   / 
A---B---C master                                       A---B---C master


            F---G topic <- HEAD                                                    D---E branch
           /                                                                      / 
      D---E branch                (git rebase --onto master branch topic)        /   F'---G' topic <- HEAD
     /                                                                          /   / 
A---B---C master                                                           A---B---C master


F---G alien                                                                A'---B'---C' branch <- HEAD
                                  (git rebase --root --onto alien)        /              
      D---E branch                               or                  F---G alien
     /                                   (git rebase alien)                     
A---B---C master <- HEAD                                             A---B---D---E branch

Interesting commands

.git/config and remotes

Git_Upstream.svg