如何在交互式编辑期间从 vim 内部中止 git rebase
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27226886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to abort a git rebase from inside vim during interactive editing
提问by René Link
When I do an interactive rebase, e.g.
当我进行交互式 rebase 时,例如
git rebase -i HEAD~3
the rebase interactive editor (vim in my case) opens to let me edit the commits to rebase
rebase 交互式编辑器(在我的例子中是 vim)打开让我编辑对 rebase 的提交
pick c843ea2 Set Vim column limit to 80 (OS X)
pick fc32eac Add Bash alias for `pbcopy` (OS X)
....
If I now decide that I want to abort the rebase and quit vim using :q
the rebase starts anyway. I'm using git version 1.9.0.msysgit.0
on windows.
如果我现在决定要中止 rebase 并使用:q
rebase 启动退出 vim 。我1.9.0.msysgit.0
在 Windows 上使用 git 版本。
Sure I can just delete all pick
lines, but it might be a lot to do if I rebase a longer history. Is there another way?
当然我可以删除所有pick
行,但如果我重新设置更长的历史记录,可能会有很多事情要做。还有其他方法吗?
How can I quit the rebase interactive editor (vim) and abort the rebase?
如何退出 rebase 交互式编辑器 (vim) 并中止 rebase?
回答by Telmo Costa
回答by Steven Penny
Just delete all the lines that are not comments from the file. Then save it to the default supplied path and exit the editor.
只需从文件中删除所有不是注释的行。然后将其保存到默认提供的路径并退出编辑器。
As a result git will just do nothing in this rebase.
结果 git 在这个 rebase 中什么也不做。
To delete all lines in vim you can use
要删除 vim 中的所有行,您可以使用
:%d|x
Then save and quit.
然后保存退出。
delete all lines of file in Vim
回答by CodeManX
If you're using Notepad++ on Windows for instance:
例如,如果您在 Windows 上使用 Notepad++:
CtrlAto select everything, then Delor Backspaceto delete and CtrlSsave. Git will abort the rebase if the file is empty.
CtrlA选择所有内容,然后Del或Backspace删除并CtrlS保存。如果文件为空,Git 将中止变基。
You may also hit CtrlCin the command prompt where git is running to stop the current rebase command. Then run git rebase --abort
to revert it.
您也可以CtrlC在 git 运行的命令提示符中点击以停止当前的 rebase 命令。然后运行git rebase --abort
以恢复它。
回答by mcandre
Delete all text in your text editor screen, then save the file with the default supplied path.
删除文本编辑器屏幕中的所有文本,然后使用默认提供的路径保存文件。