天天看點

git 分支 branch 操作

建立分支

git branch test: 基于目前commit建立test分支。.git/HEAD 檔案中記錄了目前分支名字。      

删除分支

git branch -d test:删除本地test分支

git branch -D test: test分支還沒有合入目前分支,是以要用-D參數才能删掉。

git push origin --delete test 删除遠端test分支

git push origin :test 删除遠端test分支      

檢視分支

git branch 列出目前分支清單

git branch -a 檢視遠端分支和本地分支

git branch -v 檢視各個分支最後一個送出資訊

git branch --merged 檢視哪些分支已經合并入目前分支      

拉取分支 

git fetch origin 同步遠端伺服器的資料到本地

git checkout -b test origin/test_remote 将遠端分支test_remote拉取下來到本地test分支

git checkout test 将遠端分支test拉取下來到本地test分支

git pull test從遠端分支test 中checkout下來的本地分支test成為跟蹤分支,使用git pull或者git push就會操作到對應的遠端分支test