我如何自动接受git rebase --interactive向我呈现的内容? [英] How can I automatically accept what git rebase --interactive presents to me?

查看:95
本文介绍了我如何自动接受git rebase --interactive向我呈现的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个小脚本修复过去的提交。该脚本假定已停止提交的修复程序,工作目录是干净的,并且在命令行上传递了损坏的提交。这是脚本的原始Python核心:

 #!/ usr / bin / env python 
import os
import sys

broken_commit = sys.argv [1]

logmsg = os.popen(git log --format = %% s%s〜1 .. %s%(broken_commit,broken_commit),'r').read()。strip()
os.system(git commit --message \fixup!%s\%logmsg)
os.system(git rebase --interactive --autosquash%s〜2%broken_commit)

此时,我会看到一个编辑器,只需确认(在我的例子中为:wq )显示的更改。我怎样才能避免这最后一步?我希望 git rebase 这一行不会让我有机会编辑显示的步骤。



我听说你可以通过EDITOR环境变量设置特殊的脚本来实现。然而,我在Windows上使用msysGit,所以我在这方面有点局限。

解决方案

设置环境变量在运行 git rebase 之前, EDITOR 至 true 会让它接受显示的内容会自动变化。

I'm using a little script to fix up past commits. The script assumes that the fix for the broken commit is staged, that the working directory is clean and that broken commit is passed on the command line. Here's the raw Python core of the script:

#!/usr/bin/env python
import os
import sys

broken_commit = sys.argv[1]

logmsg = os.popen( "git log --format=%%s %s~1..%s" % ( broken_commit, broken_commit ), 'r' ).read().strip()
os.system( "git commit --message \"fixup! %s\"" % logmsg )
os.system( "git rebase --interactive --autosquash %s~2" % broken_commit )

At this point, I'm presented with an editor and just need to confirm (:wq in my case) the shown changes. How can I avoid this last step? I'd like the git rebase line to just go on without giving me the chance to edit the steps shown.

I heard you could have special script set via the EDITOR environment variable to achieve. However, I'm using msysGit on Windows, so I'm a bit limited in that area.

解决方案

Setting the environment variable EDITOR to true before running git rebase will make it accept the shown changes automatically.

这篇关于我如何自动接受git rebase --interactive向我呈现的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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