如何以非交互方式运行git rebase --interactive? [英] How do I run git rebase --interactive in non-interactive manner?
问题描述
$ b
- 制作
git rebase --interactive
只是将标准样板文件输出到文件,而不是输出到文件并在编辑器中打开。 - 让用户编辑文件。
- 让用户用编辑文件的名称重新运行
git rebase
。 - 继续平常的rebase过程。 >
Usecase:脚本重新绑定当然。请参阅如何在Git中非交互式地重新提交提交例如。
经过一番思考和研究后,答案变得微不足道: git rebase -i
从知名的EDITOR / VISUAL环境变量中获取编辑器名称,因此覆盖指向非交互式脚本即可完成这项工作。然而,EDITOR / VISUAL无所谓地应用于提交列表,提交重新字符时的提交消息以及其他任何内容。所以,由于 http://git.kernel。 org /?p = git / git.git; a = commit; h = 821881d88d3012a64a52ece9a8c2571ca00c35cd ,有一个特殊的环境变量GIT_SEQUENCE_EDITOR,它仅适用于提交列表。
<因此,重新排序或压扁提交的方法是:
运行: GIT_SEQUENCE_EDITOR =< script> git rebase -i< params>
。
您的< script>
应该接受一个参数:包含标准rebase commit列表的文件的路径。它应该重写它并退出。常见的rebase处理发生在那之后。
Is it possible to do following?
- Make
git rebase --interactive
to just output standard boilerplate to a file, instead to outputting to a file and opening it in editor. - Let the user edit the file.
- Let user re-run
git rebase
with the name of edited file. - Go on with the usual rebase process.
Usecase: scripted rebasing of course. See how to re-order commits in Git non-interactively for example.
After some thinking and research, the answer turned out to be trivial: git rebase -i
takes the editor name from the well-known EDITOR/VISUAL environment variables, so overriding that to point to a non-interactive script does the job.
However, EDITOR/VISUAL applies indifferently to the list of commits, commit messages when rewording and anything else. So, since http://git.kernel.org/?p=git/git.git;a=commit;h=821881d88d3012a64a52ece9a8c2571ca00c35cd , there's a special environment variable GIT_SEQUENCE_EDITOR which applies only to the commit list.
So, the recipe to re-order or flatten commits is:
Run: GIT_SEQUENCE_EDITOR=<script> git rebase -i <params>
.
Your <script>
should accept a single argument: the path to the file containing the standard rebase commit list. It should rewrite it in-place and exit. Usual rebase processing happens after that.
这篇关于如何以非交互方式运行git rebase --interactive?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!