[英]How to unstage a deleted file in git
I realize this question has been answered in other threads. 我知道这个问题已经在其他线程中得到了解答。 However, my issue (I believe) is unique. 但是,我的问题(我相信)是独一无二的。
Backstory: I am a git bash noob. 背景故事:我是git bash 菜鸟 。 I only recently started using it, and as a result, have done quite a few dumb things. 我直到最近才开始使用它,因此,做了很多愚蠢的事情。 I create a test file, AWACSfile.txt
, staged it with git add
. 我创建了一个测试文件AWACSfile.txt
,并使用git add
进行了git add
。 I then did git commit
, and here is where the problems started. 然后我做了git commit
,这是问题开始的地方。
It brought up a new screen & prompted me for notes (or some other requirement when staging) that I did not add to the commit
line. 它弹出一个新屏幕,并提示我输入我未添加到commit
行的注释(或登台时的其他要求)。 At that point, I didn't know what to do and attempted to exit the bash shell. 那时,我不知道该怎么办,并试图退出bash shell。
It gave me a warning saying processes were still open. 它给了我一个警告,说程序仍在打开。 I ignored it, assuming that they would terminate when I exited the shell. 我忽略了它,假设它们在退出外壳时会终止。 Wrong . 错了 。 Following that, I was unable to merge branches, switch branches, I could not delete the file, I could not unstage the file, I cannot do anything really without it giving me the attached error: 之后,我无法合并分支,切换分支,无法删除文件,无法取消暂存文件,没有它给我附加的错误,我将无法做任何事情:
I attempted to delete the index.lock
file as well, but same error was met. 我也尝试删除index.lock
文件,但遇到相同的错误。 I'm at a point where I have no idea what to do - I even tried uninstalling & it wouldn't uninstall because the process is still open with no force kill. 我现在不知道该怎么办-我什至尝试卸载&不会卸载,因为该过程仍处于打开状态并且没有强制终止。
It gave me a warning saying processes were still open. 它给了我一个警告,说程序仍在打开。 I ignored it, assuming that they would terminate when I exited the shell. 我忽略了它,假设它们在退出外壳时会终止。 Wrong. 错误。
Windows has mandatory file locking , meaning if a process has a file open you cannot delete it. Windows具有强制性文件锁定功能 ,这意味着如果进程打开了文件,则无法将其删除。 Something is holding onto index.lock
and shutting down the shell might not kill it. 保留了index.lock
并关闭外壳可能无法杀死它。
Without seeing your previous Git history I can't say what that process might be. 没有看到您以前的Git历史记录,我无法说出该过程可能是什么。 It could be any number of things which use index.lock
hanging. 可能有许多使用index.lock
挂起的东西。 An editor process used by git commit
could be the culprit. git commit
使用的编辑器进程可能是罪魁祸首。 You could find the process which is holding index.lock
open and kill it. 您可以找到保持index.lock
打开并杀死它的进程 。
Or you can try turning it off and on again: ie. 或者,您可以尝试将其关闭然后再打开:即。 restart your computer to ensure any hanging processes are stopped. 重新启动计算机,以确保所有挂起的进程都已停止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.