撤消StGit rebase?

时间:2011-12-15 00:07:32

标签: git git-rebase

我使用Stacked Git针对上游Perforce存储库维护了大量补丁。我在签出的Perforce树的根目录中做了一个'git init',并在那里提交了'pristine'上游源代码。然后我在本地克隆了那个git repo以创建我的补丁系列。

我定期从Perforce服务器下载更新,将它们提交到'pristine'git镜像,然后执行:

$ git remote update
$ stg rebase remotes/origin/master

这通常是直截了当的,但偶尔有人会以微不足道的方式触及数十个上游文件(例如,使用uncrustify),这会产生大量冲突。当发生这种情况时,在那时和那里对我的补丁进行分类并不总是方便的;有时候我会忘记整件事,只是继续工作。

要使用标准git处理这种情况,我会创建一个临时分支来拉/合并(或rebase),如果我喜欢最终结果,删除我的主分支并将temp分支重命名为master。我还没有弄清楚如何使用stgit实现相同的功能。

我遇到this SO question关于撤消标准git rebase的问题,但是stgit可以使用相同的技术吗?

更新 [12/15/2011]:我觉得有必要陈述一些可能不明显的事情 - stg undo (显然)做我想做的事:

$ stg status
$ stg series
+ add-copyright-notice
+ add-bn-namespace
> fix-tabs
$ git remote update
Fetching origin
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From c:/d/projects/luasand
   57afdac..6b4b209  master     -> origin/master
$ stg rebase remotes/origin/master
Checking for changes in the working directory ... done
Popping all applied patches ... done
Rebasing to "remotes/origin/master" ... done
Pushing patch "add-copyright-notice" ...
  CONFLICT (content): Merge conflict in Variant.h
Error: The merge failed during "push".
       Revert the operation with "stg undo".
stg rebase: 1 conflict(s)
$ stg status
UU Variant.h
M  main.cpp
$ stg undo
Error: Need to resolve conflicts first
stg undo: Command aborted (all changes rolled back)

在上面显示的场景中,我只是想假装我从未输入stg rebase ...并继续工作,将rebase推迟到更方便的时间。它告诉我使用stg undo恢复,然后告诉我必须首先解决冲突(?!)我怎么能告诉StGit忘记整个事情?

1 个答案:

答案 0 :(得分:2)

好吧,即使我不喜欢自己的答案,我也会自己回答这个问题。 stg reset --hard似乎做了我想要的事情:

$ stg series
+ add-copyright-notice
+ add-bn-namespace
> fix-tabs
$ git remote update
Fetching origin
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From c:/d/projects/luasand
   57afdac..d340a1a  master     -> origin/master
$ stg rebase remotes/origin/master
Checking for changes in the working directory ... done
Popping all applied patches ... done
Rebasing to "remotes/origin/master" ... done
Pushing patch "add-copyright-notice" ...
  CONFLICT (content): Merge conflict in Variant.h
Error: The merge failed during "push".
       Revert the operation with "stg undo".
stg rebase: 1 conflict(s)
$ stg log
f2af21a   Thu, 15 Dec 2011 13:23:54 -0500   rebase (CONFLICT)
ebe140c   Thu, 15 Dec 2011 13:23:53 -0500   rebase
a04604e   Thu, 15 Dec 2011 13:22:29 -0500   refresh
a83f169   Thu, 15 Dec 2011 13:22:28 -0500   refresh (create temporary patch)
c2a57d8   Thu, 15 Dec 2011 13:21:50 -0500   new
1770c17   Thu, 15 Dec 2011 13:21:44 -0500   refresh
7613544   Thu, 15 Dec 2011 13:21:44 -0500   refresh (create temporary patch)
bf19372   Thu, 15 Dec 2011 13:20:49 -0500   new
7a67f4c   Thu, 15 Dec 2011 13:20:43 -0500   refresh
ae42ad2   Thu, 15 Dec 2011 13:20:42 -0500   refresh (create temporary patch)
8c91906   Thu, 15 Dec 2011 13:20:12 -0500   new
2b75e5f   Thu, 15 Dec 2011 13:20:11 -0500   start of log
$ stg reset --hard a04604e
Now at patch "fix-tabs"
$ stg series
+ add-copyright-notice
+ add-bn-namespace
> fix-tabs

这似乎有效,但我更喜欢不依赖于在主分支上执行reset --hard的解决方案。我用这个命令几次用脚射击自己,所以现在我总是使用p上描述的“西斯大师”技巧。 Git From The Bottom Up的25-26。

所以...这是我原来问题的 答案,但我希望有人会发布一个更好的问题。

相关问题