On Github chenqingspring / git-checkout-slides
Created by CHEN Qing @ThoughtWorks
blob object
tree object
commit object
git checkout .
git checkout text.txt
git checkout sprint221
git checkout 384f5ad
also...
git checkout text.txt 384f5ad
git checkout HEAD~2
Updates files in the working tree to match the version in the index or the specified tree
If no paths are given, git checkout will also update HEAD to set the specified branch as the current branch
Working Tree = Tracked = Local Repo + index + unstaged
Working Directory = Tracked + Untracked
index -> git ls-files --stage
unstaged = Tracked - (Local Repo + index)
HEAD -> cat .git/HEAD
branch -> cat .git/refs/heads/master
Updates files in the working tree to match the version in the index or the specified tree
If no paths are given, git checkout will also update HEAD to set the specified branch as the current branch
HEAD !-> branch
git init
echo "test" >> file.txt
git add .
echo "test" >> file.txt
git checkout HEAD
git checkout .
A. Clean Working Tree B. Only index exists
C. index & unstaged exist D. HEAD becomes deteched
- Git Checkout - What is HEAD in Git - Git Index - Git Objects