Git版本管理 本地分支與遠程分支同名進行關聯

:git branch
* master
:git branch -r
  origin/HEAD -> origin/master
  origin/master
  origin/zhaolu
:git branch zhaolu
:git checkout zhaolu
:cat 1
:

本地新建一個分支與遠程分支同名,但是不會是遠程分支的內容。

如果要進行關聯:

:git merge origin/zhaolu
更新 79e6fbe..534144c
Fast-forward
 1 | 1 +
 1 file changed, 1 insertion(+)
:cat 1
hello world
:ls
1	2	3
:cat >> 1 << EOF
> 123
> EOF
:cat 1
hello world
123
:git add 1
:git commit -m update\ 1 1
[zhaolu 5195b9c] update 1
 1 file changed, 1 insertion(+)
:git push origin zhaolu
枚舉對象: 5, 完成.
對象計數中: 100% (5/5), 完成.
使用 4 個線程進行壓縮
壓縮對象中: 100% (2/2), 完成.
寫入對象中: 100% (3/3), 272 bytes | 272.00 KiB/s, 完成.
總共 3 (差異 0),複用 0 (差異 0)
To https://github.com/LLLUZHAO/Test.git
   534144c..5195b9c  zhaolu -> zhaolu

感覺應該是:

git branch --set-upstream-to=origin/zhaolu

測試以下:

:git clone https://github.com/LLLUZHAO/Test.git
正克隆到 'Test'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 15 (delta 1), reused 15 (delta 1), pack-reused 0
展開對象中: 100% (15/15), 完成.
:cd T*
:ls
1	2	3
:git branch
* master
:git branch -r
  origin/HEAD -> origin/master
  origin/master
  origin/zhaolu
:git branch --set-upstream-to=origin/zhaolu
分支 'master' 設置爲跟蹤來自 'origin' 的遠程分支 'zhaolu'

這個命令是把當前分支跟蹤,應該是:

:git clone https://github.com/LLLUZHAO/Test.git
正克隆到 'Test'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 15 (delta 1), reused 15 (delta 1), pack-reused 0
展開對象中: 100% (15/15), 完成.
:cd Test
:git branch zhaolu
:git checkout zhaolu
切換到分支 'zhaolu'
:git branch --set-upstream-to=origin/zhaolu
分支 'zhaolu' 設置爲跟蹤來自 'origin' 的遠程分支 'zhaolu'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章