zoukankan      html  css  js  c++  java
  • git 的版本回滚

    当用git clone 复制远程代码库到本地时,使用 git branch 只能看到默认库(master),当远程库有多个分支时,可以使用 git branch -a 查看全部的分支,

    然后git checkout 分支名  来切换分支

    参考:

    http://blog.csdn.net/xqs83/article/details/7382074

    http://www.wiloon.com/wordpress/?p=2582

    http://blog.csdn.net/arkblue/article/details/9568249

    git代码库回滚: 指的是将代码库某分支退回到以前的某个commit id

    【本地代码库回滚】:

    git reset --hard commit-id :回滚到commit-id,讲commit-id之后提交的commit都去除

    git reset --hard HEAD~3:将最近3次的提交回滚

    【远程代码库回滚】:

    这个是重点要说的内容,过程比本地回滚要复杂

    应用场景:自动部署系统发布后发现问题,需要回滚到某一个commit,再重新发布

    原理:先将本地分支退回到某个commit,删除远程分支,再重新push本地分支

    操作步骤:

    1、git checkout the_branch

    2、git pull

    3、git branch the_branch_backup //备份一下这个分支当前的情况

    4、git reset --hard the_commit_id //把the_branch本地回滚到the_commit_id  只有使用--hard才会更改本地,要不只更新暂存区,硬盘上不变

    5、git push origin :the_branch //删除远程 the_branch  这个方法在新版本上不能用,

        可以参见这个方法:http://zengrong.net/post/1746.htm

    6、git push origin the_branch //用回滚后的本地分支重新建立远程分支

    7、git push origin :the_branch_backup //如果前面都成功了,删除这个备份分支

    如果使用了gerrit做远程代码中心库和code review平台,需要确保操作git的用户具备分支的push权限,并且选择了 Force Push选项(在push权限设置里有这个选项)

    另外,gerrit中心库是个bare库,将HEAD默认指向了master,因此master分支是不能进行删除操作的,最好不要选择删除master分支的策略,换用其他分支。如果一定要这样做,可以考虑到gerrit服务器上修改HEAD指针。。。不建议这样搞

    原文:http://www.cnblogs.com/qualitysong/archive/2012/11/27/2791486.html

    图解git 不错:http://www.cnblogs.com/hnrainll/archive/2013/03/19/2968449.html

  • 相关阅读:
    A CIRCULAR PROGRESSBAR STYLE USING AN ATTACHED VIEWMODEL
    First MarkDown Blog
    Folder Recursion with C#
    39. Volume Rendering Techniques
    Service Station
    WPF Wonders: Transformations (and Robots!)
    Flipping elements with WPF
    FoLlow 的技术博客
    利用索引降低并发事务引起的锁【转】
    企业级应用架构模型-并发,事务,锁
  • 原文地址:https://www.cnblogs.com/zhouxiuquan/p/3678925.html
Copyright © 2011-2022 走看看