简体   繁体   English

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

[英]How to revert multiple commit from branch created out of master?

How can I revert multiple commits from a branch created out of master ? 如何从master以外的分支还原多个提交?

I created a release- 1.1 from master. 我从母版创建了1.1 Master includes a jira with following commits. Master包含一个带有以下提交的jira。 A jira has around 50 commits. 一个jira大约有50次提交。 Example as below , it has also merge commits in between marked (M) 下面的示例,它还在标记(M)之间合并了提交

commits 提交

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

Here is the technique - 这是技术-

Method 1 : Cherry-pick Your Commits alone. 方法1:独自挑选Your Commits
I guess, you do not have to think about others commit. 我猜,您不必考虑其他人的承诺。 So just pick your commits and go ahead. 因此,只需选择您的提交并继续。

Commands to follow: 遵循的命令:

Assuming commit x & y are committed by you. 假设提交x和y由您提交。
Assuming you are in the branch (jira branch) 假设您在分支(jira分支)中
a. 一种。 git fetch origin
b. git log --oneline -30 #Note down your commit ID somewhere (x&y) git log --oneline -30 #在某处记下您的提交ID(x&y)
c. C。 git reset --hard origin/master #BE CAREFUL there should not be any non committed files. git reset --hard origin/master #要小心,不应有任何未提交的文件。 Which will destroy this command, if any! 如果有的话,它将破坏该命令!
d. d。 git cherry-pick commit-x
e. git cherry-pick commit-y
g. G。 Do the required code changes for reverting Do the required code changes以还原
h. H。 git commit.. new changes f. git commit..新更改f。 git log --oneline -20 #to confirm git log --oneline -20 #确认


Method 2 : Use revert command. 方法2 :使用还原命令。
Assuming commit-a and commit-b you want to revert 假设您要还原commit-a和commit-b
a. 一种。 git revert commit-a
b. git revert commit-b
Please note, this will create new two commits above all. 请注意,这将首先创建两个新提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM