Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何抑制“git-rebase--continue”的编辑器?_Git_Macos_Command Line_Git Rewrite History - Fatal编程技术网

如何抑制“git-rebase--continue”的编辑器?

如何抑制“git-rebase--continue”的编辑器?,git,macos,command-line,git-rewrite-history,Git,Macos,Command Line,Git Rewrite History,我经常重新设置interactive的基调,以便在历史记录中进行微小的更改(例如删除一个空行或编辑一行)。在大多数情况下,这些变化是基于一些同行审查 起初我是这样做的: git rebase --interactive 83bbeb27fcb1b5e164318fa17c55b7a38e5d3c9d~ # replace "pick" by "edit" on the first line # modify code git commit --all --amend --no-edit git

我经常重新设置interactive的基调,以便在历史记录中进行微小的更改(例如删除一个空行或编辑一行)。在大多数情况下,这些变化是基于一些同行审查

起初我是这样做的:

git rebase --interactive 83bbeb27fcb1b5e164318fa17c55b7a38e5d3c9d~
# replace "pick" by "edit" on the first line
# modify code
git commit --all --amend --no-edit
git rebase --continue
如果以下提交之一中存在合并冲突,我将解决这些冲突并执行以下操作:

git rebase --continue
# the commit message is shown, but does not have to be changed, so I just save and exit the editor
git rebase --continue
# the commit message is shown, but does not have to be changed, so I just save and exit the editor
git rebase --continue
# the commit message is shown, but does not have to be changed, so I just save and exit the editor
...
是否有类似于
--no edit
参数的
git-rebase--continue
方法可以避免编辑器(类似于
git-commit

GIT_EDITOR=true git rebase --continue
这将覆盖
git
用于消息确认的编辑器
true
命令以零退出代码结束。它使
git
继续
rebase
就好像用户关闭了交互式编辑器一样

在Windows上,您需要

cmd/V/C“设置”GIT_EDITOR=true&&GIT-rebase——继续
在这两种操作系统中,都可以使用别名

#Linux
别名grc='GIT_EDITOR=true GIT-rebase--continue'
#窗户
doskey grc=cmd/V/C“设置”GIT_EDITOR=true“&&GIT-rebase——继续”

然后,一个简单的
grc
就足以继续使用rebase,而不会弹出编辑器。

将首选编辑器设置为“不执行任何操作并成功”命令,例如
true
。Git将调用它,它将不执行任何操作并成功,Git将重新使用现有的提交消息。因此:
Git\u editor=true Git rebase--continue
@torek是否有办法将编辑器的更改仅应用于一个git命令?我尝试了
(比如:
git_editor=true;git rebase--continue
),但没有成功。(我使用的是mac,顺便说一句)这(通过shell的环境设置
VAR=val cmd…
)只影响一个命令,以及它自身运行的任何命令。要影响多个命令,必须设置变量和“导出”“它,在大多数shell中是
export VAR=value;命令1;命令2设置环境变量,如
var=val
仅适用于shell。为了使ti适用于此后将启动的所有进程,您需要调用
export var
。作为单个命令执行任何操作都可以是
export var=val
。但是,对于
GIT
的所有其他调用,覆盖
GIT\u编辑器
是个坏主意。因此,最后的建议(
var=val command
)是最好的,因为它没有负面的副作用。@VictorYarema感谢您的评论和编辑:感谢您,这个答案现在更清楚了。非常漂亮!