天天看點

git tracked branch

Tracking branch

local分支track的remote分支,又稱為local的upstream(上遊)

create tracked branch

// 自動建立remote同名分支,并track
git checkout --track origin/serverfix

// 指定local分支名字sf
git checkout -b localBranchName origin/serverfix

// 更改目前local的遠端分支
git branch -u origin/serverfix

// 産看分支track情況(不是實時更新的,從上次更新算起(fetch、pull))
git branch -vv
           

實戰

需求:

1. v6.6疊代,在develop分支上共享代碼 (從origin倉庫的develop分支檢出代碼)

2. 你的需求 測試Git,先在自己分支feature/v6.6_test_git上開發 (開發期間,你的分支 track 你在遠端倉庫 建立的分支)

3. 最後 pull request,到develop上 (這塊不展現了)

// 從remote的git倉庫develop分支,上檢出代碼
git checkout -b feature/v6.6_test_git  origin/develop
// push本地到雲端
git push origin feature/v6.6_test_git
// 跟蹤自己push到雲端的分支
git branch -u origin/feature/v6.6_test_git
// 檢視track的分支
git branch -vv 
           

view tracked branch

git fetch --all
git branch -vv
           

delete branch

git push origin --delete serverfix
           

remote不會立即删除,而是等下次清理時(git内部機制)删除