創(chuàng)建分支:
$ [Git](http://lib.csdn.net/base/git) branch mybranch
切換分支:
$ git checkout mybranch
創(chuàng)建并切換分支:
$ git checkout -b mybranch
更新master主線上的東西到該分支上:
$git rebase master
切換到master分支:
$git checkout master
更新mybranch分支上的東西到master上:
$git rebase mybranch
提交:
git commit -a
對最近一次commit的進行修改:
之后,如果想撤銷最近一次提交(即退回到上一次版本)并本地保留代碼:
git reset HEAD^
合并分支:(merge from)
$ git checkout master$ git merge mybranch (merge from mybranch)
刪除分支:
強制刪除分支:
$ git branch -D mybranch
列出所有分支:
$ git branch
查看各個分支最后一次提交:
$ git branch -v
查看哪些分支合并入當(dāng)前分支:
$ git branch –merged
查看哪些分支未合并入當(dāng)前分支:
$ git branch –no-merged
更新遠程庫到本地:
$ git fetch origin
推送分支:
$ git push origin mybranch
取遠程分支合并到本地:
$ git merge origin/mybranch
取遠程分支并分化一個新分支:
$ git checkout -b mybranch origin/mybranch
刪除遠程分支:
$ 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
[](http://blog.csdn.net/carolzhang8406/article/details/49757101#)[](http://blog.csdn.net/carolzhang8406/article/details/49757101#)[](http://blog.csdn.net/carolzhang8406/article/details/49757101#)[](http://blog.csdn.net/carolzhang8406/article/details/49757101#)[](http://blog.csdn.net/carolzhang8406/article/details/49757101#)[](http://blog.csdn.net/carolzhang8406/article/details/49757101#)