如何从主节点以外创建的分支还原多个提交?

时间:2019-05-21 13:51:39

标签: git

如何从使用master创建的分支中还原多个提交?

我从母版创建了发行​​版1.1。 Master包含一个带有以下提交的jira。一个jira大约有50次提交。下面的示例,它还在标记(M)之间合并了提交

提交

a364478
b236478
cweyriw(M)
ywkherr
u498hsd
i93wrff(M)
eryiwrr
werkiwr 
...
...
....

1 个答案:

答案 0 :(得分:1)

这是技巧-

方法1::单独挑选git fetch origin
我猜,您不必考虑其他人的承诺。因此,只需选择您的提交并继续。

遵循的命令:

假设提交x和y是您提交的。
假设您在分支(jira分支)中
一种。 git log --oneline -30
b。 git reset --hard origin/master#记下您的提交ID(x&y)
C。 git cherry-pick commit-x#要小心,不应有任何未提交的文件。如果有的话,它将破坏该命令!
d。 git cherry-pick commit-y
e。 Do the required code changes
G。 git commit..用于恢复
H。 git log --oneline -20的新变化 F。 git revert commit-a#确认


方法2 :使用还原命令。
假设您要还原commit-a和commit-b
一种。 git revert commit-b
b。 String func(String str){ RegExp exp = RegExp(r".{1,3}"); Iterable<Match> matches = exp.allMatches(str); List<dynamic> list = []; matches.forEach((m)=>list.add(m.group(0))); return list.join(','); }
请注意,这将首先创建两个新提交。

相关问题