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/*"恢复

  • 相关阅读:
    继承ViewGroup:重写onMeasure方法和onLayout方法
    Eclipse插件的四种安装方法
    android 多条短信息发出后的状态怎样判断
    关闭windows的自动更新
    有的放矢,用好软件开发的目标管理
    安卓打包之数字签名
    PHP+jQuery实现Ajax分页效果:jPaginate插件的应用
    使用SqlDataReader获取输出参数
    ServU服务器中文乱码问题的解决
    VPS虚拟主机与VM虚拟主机对比
  • 原文地址:https://www.cnblogs.com/silvermagic/p/7665857.html
Copyright © 2011-2022 走看看