给git pull 和 git push 配置默认分支

重点是下面这个命令:
git branch --set-upstream-to=origin/one-branch one-branch
例如想把本地分支的 feature-983 跟进远程仓库的 feature-983 分支, 可以进行如下操作:
git branch --set-upstream-to=origin/feature-983 feature-983

下面是例子, 可以看到在执行 ... --set-upstream... 之前 Local branches configured for 'git pull':下的列是没有 feature-983 的, 执行之后, 就有了.

Push  URL: git@codehub.corp.com:group/oneService.git
  HEAD branch: develop
  Remote branches:
    develop-983                     tracked
    feature-983                     tracked
    master                          tracked
  Local branches configured for 'git pull':
    develop-983                     merges with remote develop-983
    master                          merges with remote master
  Local refs configured for 'git push':
    develop-983                     pushes to develop-983                     (local out of date)
    feature-983                     pushes to feature-983                     (up to date)
    master                          pushes to master                          (up to date)
[~/workspace/topsale/oneService]$ git branch --set-upstream-to=origin/feature-983 feature-983                                                                              *[feature-983] 
Branch feature-983 set up to track remote branch feature-983 from origin.
[~/workspace/topsale/oneService]$ git remote show origin                                                                                                                   *[feature-983] 
* remote origin
  Fetch URL: git@codehub.corp.com:group/oneService.git
  Push  URL: git@codehub.corp.com:group/oneService.git
  HEAD branch: develop
  Remote branches:
    develop-983                     tracked
    feature-983                     tracked
    master                          tracked
  Local branches configured for 'git pull':
    develop-983                     merges with remote develop-983
    feature-983                     merges with remote feature-983
    master                          merges with remote master
  Local refs configured for 'git push':
    develop-983                     pushes to develop-983                     (local out of date)
    feature-983                     pushes to feature-983                     (up to date)
    master                          pushes to master                          (up to date)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • origin websiteComparing WorkflowsCentralized Workflow Fea...
    伍帆阅读 524评论 0 0
  • Lesson 3: Using GitHub to Collaborate 3.1 Creating a GitH...
    赤乐君阅读 6,152评论 3 11
  • 今天第一本书《趣学算法》正式出版,三年写作,八月出版,太多的艰辛和不易。 常常坐在电脑前,就忘记喝水,忘记去卫生间...
    rainchxy阅读 266评论 0 1
  • 在每个地方,我都会把自己想要从某个东西。在每当干什么,事我会把自己想象成什么个人。 在家里,我会把...
    颜丙钰阅读 143评论 0 1
  • 人的平生总会错过许多机会,即使在阅历了一次又一次的错过,但下一次大概还会错过,天性的贪心和胆怯不停在制约着咱们。 ...
    闪光资源网阅读 658评论 0 51