您列出的步骤基本上是正确的。如果您需要将输出定向到共享驱动器,--dir 选项会很有用。如果您想导入整个补丁集,--series (-s) 选项会很有帮助。我在工作中经常使用它来在新机器上初始化一个 stg git 工作副本:
# On Machine A (existing StGit repo with all patches applied)
$ stg export --dir /y/projects/ttc_dev_stg_patches/master
Checking for changes in the working directory ... done
# On Machine B ('pristine' StGit repo with no patches)
$ stg series [<-- should have no output!]
$ stg import -s /y/projects/ttc_dev_stg_patches/master/series
Checking for changes in the working directory ... done
Importing patch "remove-stl-at" ...
Invoking the editor: "vim .stgitmsg.txt" ... done
done
Importing patch "wldap32-fix" ...
Invoking the editor: "vim .stgitmsg.txt" ... done
done
Importing patch "cmake-fixes" ...
Invoking the editor: "vim .stgitmsg.txt" ... done
done
Now at patch "cmake-fixes"
如果您不想导入每个补丁,您可以像在示例中那样单独指定它们。
另一个常见的需求是同步多个工作副本中的补丁(可能在不同的机器上)。 stg sync 是在这种情况下使用的命令:
# On Machine B (existing StGit repo)
$ stg series
+ remove-stl-at
+ wldap32-fix
> cmake-fixes
$ stg sync --all -s /y/projects/ttc_dev_stg_patches/master/series
Checking for changes in the working directory ... done
Popping patches "cmake-fixes" - "wldap32-fix" ... done
Synchronising "remove-stl-at" ... done (updated)
Fast-forwarded patch "wldap32-fix"
Synchronising "wldap32-fix" ... done
Fast-forwarded patch "cmake-fixes"
Synchronising "cmake-fixes" ... done (updated)
关于尝试取消提交具有多个父项的修订的错误:您基本上不能这样做。来自stg-uncommit(1) 手册页:
只有只有一个父级的提交才能被取消提交;其他
也就是说,你不能取消提交合并。
这是有道理的。如果历史不是线性的,StGit 就无法知道它应该使用哪个父提交。根据您的需要,一种可能的解决方法可能是从其中一个父级创建一个临时分支,然后从另一个父级中挑选您需要的提交。这将创建一个线性历史记录,然后您可以在其上运行stg uncommit 以创建一个补丁系列。如果您只是想生成一个完全适用于某些特定源树快照的补丁集,这可能没问题。但是,如果您正在做比这更复杂的事情,您很可能会在使用这种方法时遇到麻烦。 (这是一个难题;请参阅this question 了解更多信息。)