1. git init to init a working space into a git repo
  2. git add filename or git add . to track file or all files, and add them to stage
  3. git commit -m "message" to commit changes to local repo
  4. Several files can be commited together: git add file1; git add file2; git commit -m "add 2 files"
  5. Use regx: git add "*.txt"; git commit -m "add all text"
  6. git status to check which file has been modified
  7. git diff filename to check details of modification in filename
  8. git log to show logs
  9. git log --pretty to show concise info of log, git log --graph --pretty=online --abbrev-commit for more info
  10. git reset --hard HEAD^ to recover to last commit
  11. git reset --hard ID to recover to specific version
  12. git checkout -- filename to dismiss modification in local working space, e.g. if you delete text.txt in working space and want to recover it, git checkout -- text.txt can pull it from local repo to working space
  13. git reset HEAD filename to recover file from local repo
  14. rm filename to delete file in working space, only phisically delete the file without log
  15. git rm filename to delete file in working space and add a deletion operation in log waiting for commit
  16. git remote add origin **https** to connect to a remote repo
  17. git push -u origin master to push local repo to remote repo. -u for first push, it will connect local and remote repo for pull and push in future
  18. git clone **https** to clone a remote repo to local position
  19. git checkout -b dev create a new branch named dev, and switch to it. This command equals to git branch dev; git checkout dev
  20. git branch to check current branch
  21. git merge dev to merge modification from dev to current branch
  22. git branch -d dev to delete branch dev
  23. git merge is Fast Forward mode which will lose merge log, git merge --no-ff -m "merge with no-ff" will keep the merge log and make a new commit(so it needs a -m), with –no-ff you can see the merge in log

Bug Branch

git stash to keep current working space

git stash
git checkout master
git checkout -b bug-101
*fix the but*
git add .
git commit -m 'fix but-101'
git checkout master
git merge --no-ff 'merge bug-101 fix' bug-101
git branch -d but-101
git checkout dev #return to previous working branch
git stash list #check kept working space, e.g. *stash@{0}: ...
git stash apply stash@{0} #recover the working space without delete it in the list
**or**
git stash pop stash@{0} #recover and delete it in the list
`</pre>

### Omit unmerged Branch

<pre>`git checkout -b new-feature #new branch for feature development
git add featurefile
git commit -m "add new feature"
git checkout dev
*requirement changed, the feature is dismissed*
*new feature has not been merged, so need force Delete*
git branch -D new-feature
`</pre>

### Coordination

<pre>`git remote #return remote repo name, e.g. origin
git remote -v #return details
git push origin dev #push current branch to origin dev
git checkout -b dev origin/dev #create a dev, and push it to origin/dev
git pull #git fetch and merge to current branch