【Git | 工作中非常常见的远程/本地仓库分支操作】

1 篇文章 0 订阅

工作中非常常见的远程/本地仓库分支操作

  1. 本地分支操作 | 分支创建/切换

    # 本地创建新分支,并切换至该分支
    git checkout -b 'new local branch'
    # 等同于上述命令
    git branch 'new local branch' && git checkout 'new local branch'
    
  2. 远程分支操作 | 分支查看/创建

    # 查看远程所有分支
    git branch -rv
    # 查看本地分支和远程分支关联情况
    git branch -vv
    
  3. 远程仓库操作 | 仓库查看/添加

    # 查看远程仓库
    git remote
    # 添加远程仓库
    git remote add 'alias of remote rep' 'url'
    # 获取远程最新代码到本地
    git fetch 'alias of remote rep' 'branch of remote rep'
    
  4. 远程分支和本地分支的映射关系

    # 建立当前分支与指定远程分支的追踪关系,但不会拉取代码。参数"-u"和"--set-upstream-to"同样用处。
    git branch -u 'alias of remote rep'/'branch of remote rep'
    # 等同于上述命令
    git branch --set-upstream-to 'alias of remote rep'/'branch of remote rep'
    

💡 git fetchgit pull 的区别在于前者不会直接 merge , 而后者会在获取最新代码后直接 merge

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值