GIT CHECKOUT – GIT OBJECT – Usages



GIT CHECKOUT – GIT OBJECT – Usages

0 0


git-checkout-slides


On Github chenqingspring / git-checkout-slides

GIT CHECKOUT

Created by CHEN Qing @ThoughtWorks

GIT OBJECT

blob object

tree object

commit object

How to use 'CHECKOUT'?

Usages

git checkout .

git checkout text.txt

git checkout sprint221

git checkout 384f5ad

also...

git checkout text.txt 384f5ad

git checkout HEAD~2

What it is?

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

Git File Concepts

Working Tree = Tracked = Local Repo + index + unstaged

Working Directory = Tracked + Untracked

index -> git ls-files --stage

unstaged = Tracked - (Local Repo + index)

GIT HEAD

HEAD -> cat .git/HEAD

GIT BRANCH

branch -> cat .git/refs/heads/master

What is 'checkout' again?

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

Detached

HEAD !-> branch

Test

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

THANKS

- Git Checkout - What is HEAD in Git - Git Index - Git Objects

GIT CHECKOUT Created by CHEN Qing @ThoughtWorks