简体   繁体   English

在git中,如何在分支中回滚特定提交,但即使在合并之后也不会将它们回滚到父分支中?

[英]In git, how does one roll back specific commits in a branch but not roll them back in the parent branch even after merging?

Hopefully this will be an easy question. 希望这将是一个简单的问题。 I'm relatively new to git, and there are some things I still don't...git. 我对git比较新,有些事情我还是没有... git。

Hypothetical situation: 假设情况:

Suppose the develop branch contains two commits, c1 and c2. 假设develop分支包含两个提交,c1和c2。

A release branch is created after c2, so the release branch also contains c1 and c2. 在c2之后创建发布分支,因此发布分支还包含c1和c2。

Then it's decided that c1 needs to be deferred to a later release. 然后决定c1需要推迟到以后的版本。

What's the recommended way to remove c1 from the release branch without also then removing c1 from the develop branch when the release branch is merged back into develop? 当发布分支合并回develop时,从发布分支中删除c1的推荐方法是什么?

I am not sure if its recommended way or not, but it would solve your problem: 我不确定它是否推荐使用,但它可以解决您的问题:

  1. Revert commit c1 from release branch. 从发布分支恢复提交c1。 ( git revert <c1-commit-id> ) git revert <c1-commit-id>
  2. When merging the release branch to develop, revert the revert commit generated in step1. 合并release分支以进行开发时,还原在step1中生成的还原提交。 ( git revert <c1-revert-commit-id>) git revert <c1-revert-commit-id>)

Git revert command:- git revert <commit-id> Git revert命令: - git revert <commit-id>

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

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