zoukankan      html  css  js  c++  java
  • Git分支管理

    Git分支管理

    获取远程目录

    git clone ssh://UserName@RemoteIp/ProjectPath # 克隆远程git目录

    获取远程仓库分支

    git clone https://github.com/openstack/taskflow.git -b branch # 获取远程对应分支
    git checkout branch # 切换到对应分支

    $ git branch -a
    * master
      remotes/origin/HEAD -> origin/master
      remotes/origin/master
      remotes/origin/stable/kilo
      remotes/origin/stable/liberty
      remotes/origin/stable/mitaka
    
    $ git checkout stable/kilo
    Branch stable/kilo set up to track remote branch stable/kilo from origin.
    Switched to a new branch 'stable/kilo'
    
    $ git branch
      master
    * stable/kilo
    $
    

    更新分支代码

    git pull # 获取远程仓库对应分支的更新并合入本地分支
    git fetch remote remote_branch:local_branch # 获取远程仓库remote的remote_branch分支代码到本地的local_branch分支上,一般当出现git pull失败的时候,使用此种方式将远程对应分支缓存到本地,然后使用git merge local_branch的方式来更新本地分支

    $ git pull
    Already up-to-date.
    
    $ git fetch origin stable/kilo:tmp
    From https://github.com/openstack/taskflow
     * [new branch]      stable/kilo -> tmp
    

    同步代码到远程仓库

    git push # 同步当前分支到远程仓库对应分支
    git push remote local_branch:remote_branch # 同步本地local_branch分支的代码到remote仓库的remote_branch分支

    合并分支代码

    git merge branch # 合并branch分支的代码到当前分支
    git cherry-pick id # 合并其他分支的某次提交到当前分支,如果遇到冲突,需要手动修复冲突,然后使用git add添加冲突文件,然后执行git cherry-pick --continue

    批量更新分支到远程仓库

    git show-ref # git的ref相当于代码中指针的概念,每一次提交或者分支其实都是一个引用,git clone创建的副本都保存了完整的引用列表,通过git push origin "refs/remote/*:refs/heads/*"可以将本地的其他分支指针同步到服务端(服务端恢复),其中tags是唯一的,所以可以使用git push origin "refs/tags/*:refs/tags/*"恢复

  • 相关阅读:
    在线用户数与并发用户数的区别和比例关系
    MYSQL中数据类型介绍
    5分钟教你搞定RAID模式
    nginx与fastdfs配置详解与坑
    Fastdfs group通过添加硬盘扩容
    fastDfs配置文件tracker.conf配置详解
    FastDFS配置详解之Storage配置
    mysql修改库名
    vCenter Server Appliance(VCSA )6.7部署指南
    如何知道一个函数的执行时间简单案例
  • 原文地址:https://www.cnblogs.com/silvermagic/p/7665857.html
Copyright © 2011-2022 走看看