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'
发布了148 篇原创文章 · 获赞 6 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/LU_ZHAO/article/details/104901247
今日推荐