create branch: $ git branch mybranch
switch branch: $ git checkout mybranch
create and switch branch: $ git checkout -b mybranch
Update things on the master line to this branch: $ git rebase master
Switch to master branch: $ git checkout master
Update things on the mybranch branch to master: $ git rebase mybranch
Commit: git commit -a
Modify the last commit: git commit -a --amend
After committing, if you want to undo the last commit (ie go back to the previous version) and keep the code locally: git reset HEAD^
Merge branch: (merge from) $ git checkout master
$ git merge mybranch (merge from mybranch)
Delete branch: $ git branch -d mybranch
Force delete branch: $ git branch -D mybranch
List all branches: $ git branch
View the last commit of each branch: $ git branch -v
See which branches are merged into the current branch: $ git branch --merged
See which branches are not merged into the current branch: $ git branch --no-merged
Update the remote library to the local: $ git fetch origin
Push the branch: $ git push origin mybranch
Take the remote branch and merge it into the local: $ git merge origin/mybranch
Take the remote branch and fork a new branch: $ git checkout -b mybranch origin/mybranch
delete Remote branch: $ git push origin :mybranch
rebase: $ git checkout mybranch
$ git rebase master (rebase from master)
举例: $ git checkout server
$ git rebase –onto master server client
$ git checkout master
$ git merge client (fostforward)
$ git rebase master server (checkout sever)
$ git merge server
$ git branch -d client
$ git branch -d server