使用git的时候,在vim编辑界面按ctrl+z退出了,怎么回到编辑界面?

浏览:30日期:2023-09-04

问题描述

在windows上使用git,运行git commit -a命令的时候,进入了vim的编辑界面,这时不小心按ctrl+z退出了vim编辑界面,回到了命令行,并显示了这样的信息:

$ git commit -aVim: 读错误,退出中...Vim: Finished.

这时再次运行git commit -a的话,会出现以下信息:

$ git commit -a //ctrl+z退出之后再次运行git commit -afatal: Unable to create ’C:/Users/dell/gittest/.git/index.lock’: File exists.Another git process seems to be running in this repository, e.g.an editor opened by ’git commit’. Please make sure all processesare terminated then try again. If it still fails, a git processmay have crashed in this repository earlier:remove the file manually to continue.

尝试fg返回去,但是不行,显示以下信息:

$ fgbash: fg: current: no such job

应该怎么做?

问题解答

回答1:

手机上答一个,下次直接 git commit -am 'commit'

回答2:

把进程杀掉,重新commit?

回答3:

直接把提示的那个index.lock移动到文件夹以外,再试试

回答4:

Vim: 读错误,退出中...Vim: Finished.

很奇怪。(不过考虑到是 Windows,我也就释然了。)

你的 Ctrl-Z 并没有像 UNIX 系统上的那样把 Vim 放到后台,而是导致 Vim 出错退出了,所以 fg 自然就不起作用了。

你可以按第二个代码块中的提示删除锁文件。

以后不要随便按 Ctrl-Z 了。你只说了「在windows上使用git」,我并不知道你使用的是哪个版本的 git(git 官方提供的版本的是基于 msys 的;Cygwin 有自己的 git 和 Vim;msys2 也有一套;当然 WSL 还有一套……)。另外你有可能混用了不同版本的 bash 和 Vim,比如在 Cygwin 环境里使用 Windows 原生版本的 Vim。

回答5:

把这个文件删除就好了C:/Users/dell/gittest/.git/index.lock

回答6:

fg

...........................................

相关文章: