Git新建分支,本地分支關聯遠程分支

先在Git上新建分支(例:old,此時在遠程上創建了新分支)

在這裏插入圖片描述

在控制檯上新建分支並切換(此時在本地創建了新分支)

1: git checkout -b old (新建分支並切換) 此時直接:git branch --set-upstream-to origin/old(關聯遠程的old分支會報錯) error: the requested upstream branch ‘origin/old’ does not exist (找不到遠程old分支) 因爲你本地的倉庫無法掃描到你剛剛在遠程新建的old 2:git pull 雖然他也會報錯(當前分支沒有跟蹤信息。請指定要與哪個分支合併),但他掃描了遠程都有哪些分支了 3:再 git branch --set-upstream-to origin/old 就關聯上了。