sla*_*dan 12 git macos command-line git-rewrite-history
我经常重新定义交互式以在历史记录中进行微小的更改(例如删除空白行或编辑一行).在大多数情况下,这些变化是基于一些同行评审.
起初我做这样的改变:
git rebase --interactive 83bbeb27fcb1b5e164318fa17c55b7a38e5d3c9d~
# replace "pick" by "edit" on the first line
# modify code
git commit --all --amend --no-edit
git rebase --continue
Run Code Online (Sandbox Code Playgroud)
如果以下提交之一中存在合并冲突,我将解决它们并执行此操作:
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
...
Run Code Online (Sandbox Code Playgroud)
是否有类似的--no-edit参数git rebase --continue可以避免编辑器(类似git commit)?
小智 18
作为编辑器使用的技巧true也可以通过 git 别名来完成,如下所示:
[alias]
continue = "-c core.editor=true rebase --continue"
Run Code Online (Sandbox Code Playgroud)
然后你用git continue代替git rebase --continue.
我试过
;(像那样:)GIT_EDITOR=true;git rebase --continue,但那没用.
(我正在使用mac)
GIT_EDITOR=true;
Run Code Online (Sandbox Code Playgroud)
这将GIT_EDITOR在当前的shell会话中设置,以便遵循所有命令.
使用:
GIT_EDITOR=true git rebase --continue
Run Code Online (Sandbox Code Playgroud)
它将GIT_EDITOR值作为环境变量传递给git命令分叉的子shell.
| 归档时间: |
|
| 查看次数: |
936 次 |
| 最近记录: |