2017-04-19 223 views
4

我经常通过重新设计交互来对历史进行微小的更改(例如删除空白行或编辑一行)。在大多数情况下,这些变化是基于一些同行评审。如何禁止`git rebase --continue`编辑器?

起初,我做我的变化那样:

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)?

+1

将你喜欢的编辑器设置为一个没有任何事情成功的命令,比如'true'。 Git会调用它,它什么都不做,并且会成功,Git将重新使用现有的提交消息。因此:'GIT_EDITOR = true git rebase --continue'。 – torek

+0

@torek有没有办法将编辑器的更改应用于* one * git命令?我尝试过';'(就像那样:'GIT_EDITOR = true; git rebase --continue'),但那不起作用。 (我使用的是Mac,顺便说一句) – slartidan

+0

那(环境设置通过shell'VAR = val cmd ...')*不会影响一个命令,加上它自己运行的任何东西。为了影响多个命令,你必须设置变量并“导出”它,它在大多数shell中是'export VAR = value;命令1;命令2; ...' – torek

回答

2

我试过;(像这样:GIT_EDITOR=true;git rebase --continue),但没有奏效。
(我使用的是Mac)

GIT_EDITOR=true; 

这将设置GIT_EDITOR在当前shell会话,所有命令跟随。
与之相对

GIT_EDITOR=true git rebase --continue 

其传递GIT_EDITOR值作为环境变量由git的命令叉形子壳。