在 git 或 tortoisegit 中撤消恢复

发布于 2024-09-30 02:44:18 字数 255 浏览 0 评论 0原文

有没有一种简单的方法可以撤消 tortoisegit 恢复?

这里有更多信息:我刚刚提交了一个大型的多文件签入,然后我决定在大签入之前提交一个单独的小签入,以便明天更容易修改该大签入。

所以我打开了 tortoisegit 的日志,右键单击上次签入,然后选择“恢复”。这撤消了更改并删除了我的工作目录中的一堆文件。我真正想要的是“重置”(回滚签入并按原样保留我的工作目录),而不是恢复(在我的工作目录中创建“撤消签入”)。

我怎样才能撤消我的恢复?

Is there an easy way to undo a tortoisegit revert?

Here's more info: I just committed a large multi-file checkin, and right afterwards decided I instead wanted to commit a separate small checkin before the big one, to make it easier to amend that big checkin tomorrow.

So I brought up the log in tortoisegit, right-clicked on the last checkin, and chose "revert". This undid the changes and deleted a bunch of files in my working directory. What I really wanted was "reset" (roll back a checkin and leave my working directory as is), not revert (create an "undo checkin" in my working directory).

How can I undo my revert?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我们的影子 2024-10-07 02:44:18

经过更多谷歌搜索后,我在 这篇博文:只需再次运行恢复命令,它就会撤消您的恢复,而不会因任何额外的提交而破坏您的历史记录。就好像我一开始就不会运行恢复一样。

博客文章只提到了常规(命令行)git 的这个技巧,但同样的事情也适用于 tortoisegit。特别好的一点是,我的工作目录中的其他更改不会消失——只有恢复被撤消。

我将自行生成的问答对留在这里,因为找到这个答案有点困难——希望能帮助其他人节省时间。

After more Googling, I found the answer in this blog post: simply run the revert command again and it will undo your revert without littering your history with any extra commits. It's as if I'd never run revert in the first place.

The blog post only mentions this trick for regular (command-line) git, but the same thing works in tortoisegit. What's particularly nice is that other changes in my working directory are not blown away-- only the revert is undone.

I'm leaving the self-generated Q&A pair here, since it was kinda hard to find this answer-- hopefully will help someone else save time.

梓梦 2024-10-07 02:44:18

无论如何,只需将 git Reset 重置到您想要的位置即可。 revert 没什么特别的:它只是一个普通的提交,其行为与另一个提交的行为完全相反。由于这只是一个普通的提交,因此它将像您最初想要删除的其他提交一样被垃圾收集。

Just git reset to the point you wanted to, anyway. A revert is nothing special: it is just a normal commit which does the exact opposite of what another commit does. Since it is just a normal commit, it will be garbage collected just like the other commit(s) you originally wanted to get rid of.

嗳卜坏 2024-10-07 02:44:18

我尝试恢复之前恢复的提交,但什么也没做。结果是“没有什么可提交的(工作目录干净)”。

有效的方法是挑选以前恢复的提交。这引入了我之前恢复的更改,并且没有更改我的工作目录。

I tried reverting a commit that I had previously reverted, and it did nothing. The result was "nothing to commit (working directory clean)".

What did work was cherry-picking the formerly reverted commit. That pulled in the changes that I had formerly reverted and did not otherwise alter my working directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文