zoukankan      html  css  js  c++  java
  • Git cherrypick

      假设你在dev01分支开发了2个新功能(A,B),对应2个commitA,commitB,但是上线前被告知只能上线功能A,此时可以:

    1. 新建1个分支dev02

    2. 将dev01上功能A对应代码cherry-pick到dev02上,dev02就有了功能A对应的代码

    • cherry-pick的用法:
    • $ git cherry-pick 6bbf6b4 #6bbf6b4为dev01上的commitId
    • 举个栗子:

       把dev01分支上的commit(增加1个文件),cherry-pick应用到dev02分支上。

    • /code/lianxi (dev01)
      $ git commit -m "add 1.txt"    #dev01分支提交了1个commit 6bbf6b4
      [dev01 6bbf6b4] add 1.txt
      file changed, 1 insertion(+)
       create mode 100644 1.txt
      
      /code/lianxi (dev01)
      $ git log
      commit 6bbf6b4568d3b657dcfe06f06a69bd250c769942  #commit 信息
      Author: a
      Date:   Wed Jun 7 17:45:28 2017 +0800
      
          add 1.txt
      
      /code/lianxi (dev01)
      $ git checkout dev02 #切换到dev02分支操作
      Switched to branch 'dev02'
      
      /code/lianxi (dev02)
      $ ls #dev02下此时没有1.txt
      
      /code/lianxi (dev02)
      $ git cherry-pick 6bbf6b4 #将commit6bbf6b4 应用到dev02上
       [dev02 5e716f5] add 1.txt Date: Wed Jun 7 17:45:28 2017 +0800 file changed, 1 insertion(+) create mode 100644 1.txt 

      /code/lianxi (dev02)
      $ git log #在dev02会产生1个新的commitId,内容为commit 6bbf6b4改动的内容
      commit 5e716f52a541098afd0a0b74551878d119f97d14 
      Author: a
      Date: Wed Jun
      7 17:45:28 2017 +0800
      add
      1.txt

      /code/lianxi (dev02)
      $ ls #dev02也有了1.txt
      1.txt
  • 相关阅读:
    mysql性能分析工具
    vim使用大全
    Vue computed属性
    模板题 + KMP + 求最小循环节 --- HDU 3746 Cyclic Nacklace
    Greedy --- HNU 13320 Please, go first
    DFS --- HNU 13307 Galaxy collision
    HNU 13308 Help cupid
    Linux
    dp
    2015 Multi-University Training Contest 2 1006 Friends
  • 原文地址:https://www.cnblogs.com/yangweiqiang/p/6958464.html
Copyright © 2011-2022 走看看