git initto init a working space into a git repogit add filenameorgit add .to track file or all files, and add them to stagegit commit -m "message"to commit changes to local repo- Several files can be commited together:
git add file1; git add file2; git commit -m "add 2 files" - Use regx:
git add "*.txt"; git commit -m "add all text" git statusto check which file has been modifiedgit diff filenameto check details of modification in filenamegit logto show logsgit log --prettyto show concise info of log,git log --graph --pretty=online --abbrev-commitfor more infogit reset --hard HEAD^to recover to last commitgit reset --hard IDto recover to specific versiongit checkout -- filenameto dismiss modification in local working space, e.g. if you delete text.txt in working space and want to recover it,git checkout -- text.txtcan pull it from local repo to working spacegit reset HEAD filenameto recover file from local reporm filenameto delete file in working space, only phisically delete the file without loggit rm filenameto delete file in working space and add a deletion operation in log waiting for commitgit remote add origin **https**to connect to a remote repogit push -u origin masterto push local repo to remote repo.-ufor first push, it will connect local and remote repo for pull and push in futuregit clone **https**to clone a remote repo to local positiongit checkout -b devcreate a new branch named dev, and switch to it. This command equals togit branch dev; git checkout devgit branchto check current branchgit merge devto merge modification from dev to current branchgit branch -d devto delete branch devgit mergeis 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


