在fugitive-plugin 状态窗口中,使用 访问时,可以使用:Gstatusdiff 更改文件D并切换文件以使用 提交-。
是否有任何类似的丢弃更改的快捷方式,丢弃我的意思是相当于git checkout -- filename?
更新:
在逃犯github页面上发现了一个功能请求问题 #97:结帐/删除文件的快捷方式
据此,首选方式是使用 :Gread :w
更新 2:
自 2014 年 6 月起,可以使用下面Anson 的U回答。
更新 3: 自2019 年 1 月 3 日起,键绑定映射到X
Ans*_*son 38
截至 2019 年:
此功能映射到X. 这是:h fugitive-staging-maps关于它的内容:
X Discard the change under the cursor. This uses
`checkout` or `clean` under the hood. A command is
echoed that shows how to undo the change. Consult
`:messages` to see it again. You can use this during
a merge conflict do discard "our" changes (--theirs)
in the "Unstaged" section or discard "their" changes
(--ours) in the "Staged" section.
Run Code Online (Sandbox Code Playgroud)
对于历史背景:
此功能于 2014 年 6 月添加,默认情况下映射到U.
功能请求和讨论:https :
//github.com/tpope/vim-fugitive/issues/97
提交:https :
//github.com/tpope/vim-fugitive/commit/061a81f247538aeb61e165e1551355f289d52f63
Chr*_*sen 20
您可以使用fugitive的Gread命令用缓冲区文件的各种替代版本替换缓冲区的内容(即这必须从文件的缓冲区完成,而不是从:Gstatus缓冲区)。
:Gread(不带参数)将使用索引†中的文件版本。:Gread - 将使用 HEAD 提交中的文件版本。有关逃犯支持:help fugitive-revision的其他修订规范列表,请参阅文档(上述两个可能是最直接有用的)。
该:Gread工作流进行这样的:
:Gread:w将文件保存到工作树(或者,:Gread|w如果您知道要立即保存它,则使用)。该:Git checkout -- %工作流进行这样的:
:Git checkout -- %总结::Gread避免“文件自编辑开始后已更改”提示,让您决定何时修改工作树中的文件。
†当缓冲区代表文件的索引阶段而不是工作树中的文件时,:Gread从文件的内容中读取,因为它存在于工作树中的磁盘上,而不是索引的阶段 0。