local repository

checkout

checkout <branch>

switch branch

git checkout dev

checkout-branch

checkout <commit> [files]

<commit> is HEAD by default. The current branch doesn’t change, without moving the HEAD pointer location.

copy the <commit> tree to index tree and working tree.

git checkout HEAD
git checkout HEAD^
git checkout HEAD~3 1.txt
git checkout a47c3

chckout-files

reset

reset <commit> [files]

move the HEAD, and copying <commit> tree to index or working tree.

three mode:

–soft: no copy. move HEAD

–mixed: copy to index only. move HEAD   = reverse git add

–hard: copy to index and working tree. move HEAD  

git reset HEAD^3
git reset HEAD 1.txt  = reset -- 1.txt
git reset HEAD^ 1.txt

reset-commit

diff

git diff

working <=> index

git diff –cache

index <=> HEAD

git diff HEAD

working <=> HEAD

git diff HEAD^^

working <=> HEAD^^

git diff da985 b325c

da985 <=> b325c

git diff <branch>

working <=> <branch> HEAD

git-diff

merge

fast-forward merge

ff-merge

3-way merge

3-way-merge

cherry-pick and rebase

cherry-pick

rebase

remote repository

remote

remote
remote -v

remote add &lt;remote_repo_name> &lt;url>
git remote add origin git@github.com:richdyang/1.git

push

push -u &lt;remote_repo_name> &lt;branch>
push

pull

git pull