Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git稳定分支:找不到_Git_Diff_Cherry Pick_Git Diff - Fatal编程技术网

git稳定分支:找不到

git稳定分支:找不到,git,diff,cherry-pick,git-diff,Git,Diff,Cherry Pick,Git Diff,我有以下git历史记录: A --- B --- C --- D' --- E' [master] \ \ --- D --- E --- F [stable] 我们有一个政策来挑选从稳定到掌握的所有变化;D'和E'是从稳定的树枝上樱桃采摘的,F不是樱桃采摘的(已被遗忘) 我怎样才能得到一个差分,使F(这不是樱桃摘进大师的) 我们不希望使用合并,因为: 没有合并提交的更干净的历史记录 对稳定的承诺很少 我们有很多不同的稳定分支 这正是该命令的目的 它不应该错过未选中的更改,但是它可能

我有以下git历史记录:

A --- B --- C --- D' --- E' [master]
 \
  \ --- D --- E --- F [stable]
我们有一个政策来挑选从稳定到掌握的所有变化;D'和E'是从稳定的树枝上樱桃采摘的,F不是樱桃采摘的(已被遗忘)

我怎样才能得到一个差分,使F(这不是樱桃摘进大师的)


我们不希望使用合并,因为:

  • 没有合并提交的更干净的历史记录
  • 对稳定的承诺很少
  • 我们有很多不同的稳定分支
    • 这正是该命令的目的


      <>它不应该错过未选中的更改,但是它可能会偶尔列出一个你认为在选择的冲突解决方案中选择的更改。

      Git命令不能解决这个问题。 我已经写了这个脚本,它可以帮助


      脚本1计算分支branch1和branch2的合并基数。 然后它分别从合并基到branch1和branch2的头部创建两个列表。 然后,它使用提交消息的md5sum在branch2上创建提交的哈希表。然后检查branch1的提交列表,并检查branch2哈希表中是否存在该列表

      在上述情况下,branch1稳定,branch2为主

      #!/bin/bash
      
      ## Usage: ./missing_cherrypicks.sh branch1 branch2
      ## This script will find commits in branch1 missing in branch2
      ## Final list of missing commit will be in file missing_commits_branch1_branch2.csv
      
      branch1=$1
      branch2=$2
      
      # Calculate mergebase of branch1 and branch2
      mb=`git merge-base origin/$1 origin/$2`
      rm -rf missing_commits_${branch1}_${branch2}.csv
      echo "COMMIT,AUTHOR,MESSAGE,FILESLIST" >> missing_commits_${branch1}_${branch2}.csv
      
      # Get commit list on both branches from merge-base
      declare -a commitlist1=`git rev-list $mb..origin/$1`
      declare -a commitlist2=`git rev-list $mb..origin/$2`
      
      ## Make HashKey for branch2
      declare -A CommitHash
      for com2 in ${commitlist2[@]}
      do
        message2=`git log --pretty=oneline $com2 | head -1| sed "s/${com2} //" | sed 's/ *$//' | cut -c1-35`
        hashkey=`echo $message2 |md5sum |xargs | awk '{print $1}'`
        CommitHash[${hashkey}]=$com2
      done
      
      # Find commits of commitlist1 and check if they are in commitlist2
      for com1 in ${commitlist1[@]}
      do
         message1=`git log --pretty=oneline $com1 | head -1| sed "s/${com1} //"| sed 's/ *$//'| cut -c1-35`
         hashkey1=`echo $message1 |md5sum |xargs | awk '{print $1}'`
         if [[ -z ${CommitHash[${hashkey1}]} ]]
         then
            echo "------$com1-----------"
            author=$(git show $com1 |grep ^Author:|awk -F":" '{print $2}')
            fileslist=`git diff-tree --no-commit-id --name-only -r $com1`
            fl=""
            for file in ${fileslist[@]}
            do
                fl=${fl}":"$file
            done
      
            echo "------$author-------"
            echo "$com1,$author,$message1,$fl" >> missing_commits_${branch1}_${branch2}.csv
         fi
      done
      

      我希望它有一个选项——git日志中没有合并。@anjdreas cherry似乎没有列出合并提交,git 2.13.2。您能详细说明一下这是如何以及为什么解决OPs问题的吗?仅仅粘贴一些代码并不是一个好的答案,但从技术上讲,它可能会回答这个问题。然后它分别从合并基到branch1和branch2的头部创建两个列表。然后,它使用消息的md5sum在branch2上创建提交的哈希表。然后检查branch1的提交列表,并检查branch2哈希表中是否存在该列表。在上述情况下,branch1是稳定的,branch2是主控的。请相应地编辑您的答案,不要将详细信息添加为注释。使用脚本添加详细信息。