zoukankan      html  css  js  c++  java
  • git revert 让提交不再害怕

    git revert 让提交不再害怕

    使用了好多命令, 但对于 git revert 一直不敢怎么使用, 为什么呢?
    因为 git merge 的存在.

    每次 对于 git merge 的分支, 执行 git revert xxx 分支的时候总是报错. 没有细追.
    今天同事恰好问道了这个问题. 于是追了一下.

    主要就是对于 -m 命令. 查看了一下,其中对于

    git revert -m 
    

    解释如下

     -m parent-number, --mainline parent-number
               Usually you cannot revert a merge because you do not know which side of the merge should be considered the mainline. This option specifies the
               parent number (starting from 1) of the mainline and allows revert to reverse the change relative to the specified parent.
    
               Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a result, later merges will only bring
               in tree changes introduced by commits that are not ancestors of the previously reverted merge. This may or may not be what you want.
    
               See the revert-a-faulty-merge How-To[1] for more details.
    

    正常使用的话, 那么直接执行

    git revert xxx(具体的某次提交的 SHA-1)
    

    如果有某次merge的话

    git revert -m 1 xxx (具体的某次提交)
    

    这里的 1 是什么意思呢?

    运行 git log 后, 当前的提交信息一般如下
    commit
    Merge:
    Author:
    Date:

    其中的 merge 第一个就是 1, 第二个就是 2, 依次计算;

    一个比较好的参考地址如下:
    how to revert-a-faulty-merge

  • 相关阅读:
    9.20 kali中的Metasploit生成木马控制windows 以及http协议相关
    9.19 接上一篇,jss
    9.18 DNS服务安装
    9.17 ubuntu安装LAMP服务
    线程的安全问题
    java实现多线程(上)
    异常处理
    抽象方法和接口、内部类
    面向对象的一些关键字和方法
    Object类和包装类的一些方法
  • 原文地址:https://www.cnblogs.com/asdfq/p/9297427.html
Copyright © 2011-2022 走看看