Git basics
- http://think-like-a-git.net/
- http://marklodato.github.io/visual-git-guide/index-en.html
- https://www.atlassian.com/git/tutorials/
local repository
checkout
checkout <branch>
switch branch
git checkout dev
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
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
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
merge
fast-forward merge
3-way merge
cherry-pick and rebase
remote repository
remote
remote
remote -v
remote add <remote_repo_name> <url>
git remote add origin git@github.com:richdyang/1.git
push
push -u <remote_repo_name> <branch>
push
pull
git pull