恢复提交后如何挑选提交? [英] How to cherry pick commits after they've been reverted?

查看:80
本文介绍了恢复提交后如何挑选提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理我的feature branch,经过审查后,将其合并到development中进行部署.后来,一位同事决定进行发布,并将他和我的合并为master.部署期间,他意识到自己的代码有错误,并还原了master.

I was working on my feature branch and after review, merged it into development to be deployed. Later, a coworker decided to do a release and merged his and mine into master. While deploying he realized his code was buggy and reverted master.

在我们的分叉和拉动流程中,这意味着现在developmentmaster都已还原.

In our fork-and-pull flow, that means that now development and master are both reverted.

当我今天早上来时,我照例从开发中重新建立了基础,以了解后来发生了什么恢复.

When I came in this morning, I rebased from development per usual, to learn afterward there had been a revert.

现在,我正尝试从原始的feature branch中删除cherry-pick我的工作,只是意识到由于还原,它给了我空的提交消息".

Now I'm trying to cherry-pick my work from the original feature branch only to realize it gives me "empty commit messages" because of the revert.

  1. 这是因为还原是我以前提交的镜像吗?
  2. 有没有办法还原还原? (使我的头部受伤)
  3. 无论如何,既然我已经重新设置了基准,现在是否可以使我的提交显示在差异中

任何帮助将不胜感激.

Any help is greatly appreciated.

推荐答案

Cherry-pick和rebase检查提交的补丁ID(基本上是更改的哈希值),并且已经看到该更改存在于分支中,因此它不选择它.重新调整有时可以起作用,因为文件中的更改可能导致实际的差异有所变化(导致使用不同的补丁程序ID),但您似乎并非如此.

Cherry-pick and rebase checks the patch id of the commit (basically a hash of the change) and already sees that the change exists on the branch, so it doesn't pick it. Rebasing can sometimes work because changes in the files may have caused the actual diff to change a bit--resulting in a different patch id--but that doesn't appear to be the case for you.

您可以还原还原",尽管这将重新介绍您的同事介绍的碎片.然后,您需要还原同事所做的越野车提交.这是很多还原操作,而且要保持挺直状态,所以要慢慢来,让别人陪着您,以确保您不会错过任何事情.

You can "revert the revert", though that will re-introduce the broken bits your co-worker introduced. Then you need to revert the buggy commits your co-worker made. It's a lot of reverting, and quite a bit to keep straight, so take it slow and have someone sit with you just to make sure you don't miss anything.

另一种选择可能是通过执行git show COMMIT_ID | git apply重播您的提交.这会将差异重新应用于您的工作树.只要您的树是干净的,就可以使用git commit -C COMMIT_ID重新使用原始提交中的消息.您可能可以使用git format-patchgit am来避免多余的步骤.

Another choice might be to replay your commits by doing git show COMMIT_ID | git apply. This re-applies the diff to your working tree. As long as your tree is clean, you can use git commit -C COMMIT_ID to re-use the message from the original commit. You can probably use git format-patch and git am to avoid the extra steps.

这篇关于恢复提交后如何挑选提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆