1. git config --global user.name wenhchen
git config --global user.email "wenhui.chen@nokia-sbell.com"
ssh-keygen [-t rsa]
cat /c/Users/wenhchen/.ssh/id_rsa.pub
2. git add a.txt b.txt
git add -u # only tracked files
git add -A # all files include untracked files
3. git commit -m "modify a.txt"
git commit --amend # modify the last commit
4. git log # list commit history
git log a.txt # list a.txt commit history
git reflog # list all logs include deleted commit
5. git diff [--stat] commit_id1 commit_id2 # view the modify between two commits
6. git checkout -- a.txt # discard the modify of working dictory
git reset HEAD a.txt # move the modify from stage to working dictory
git reset --soft commit_id # delete commit info, move the modify to stage
git reset --mixed commit_id # delete commit info, move the modify to working dictory
git reset --hard commit_id # delete commit info, and delete the modify
git reset [--mixed] commit_id -- a.cpp # only modify the stage
7. git init # new an empty repo, only have .git dir
git clone xxx.git [dir] # clone one exist repo
8. git branch [-r/-a] # list branch
git branch xxx # create new branch based on current branch
git branch -d/-D xxx # delete branch
git checkout -b xxx # create and checkout new branch based on local branch
git checkout -b xxx origin/xxx # create and checkout new branch based on remote branch
9. git tag v.1.0 # create tag based on current commit
git tag v.1.0 commit_id # create tag based on specified commit
git tag # list tags
git show v.1.0 # show the tag commit info
git push origin v1.0 # push tag to remote
git tag -d v1.0 # delete local tag
git push origin :refs/tags/v1.0 # delete remote tag
10. git stash # save work directory and statge modify to stack
git stash apply # restore the modify in stack
11. git blam a.txt -L 3,5 # list the last commit info of line 3-5
git show commit_id # show commit info
12. git merge/rebase xxx # without conflict
13. git merge/rebase xxx # with conflict
14. git fetch # get all remote branch index
git push [-f] origin master # push commit to remote branch
git push origin :xxx # delete remote branch
git pull origin xxx # git fetch + git merge
git pull --rebase origin xxx # git fetch + git rebase
15. git clean -dxf