简体   繁体   English

如何在git中取消转储已删除文件

[英]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.

相关问题 如何在git log命令中排除已删除的文件? - How to exclude the deleted file in git log command? 如何查看 git 删除文件的内容(在我的例子中是一个 json 文件),然后解析它以进行处理(如清理)? - how to see contents of the git deleted file (in my case a json file) and then parse it for processing (like cleanups)? 如何 git 仅恢复已删除的文件 - How to git restore ONLY deleted files 我可以使用 git 获取已删除文件的 object 文件 ID 吗? - can I get the object file id for a deleted file with git? 安装了Git,但意外删除了一个文件。 现在我迷路了 - Installed Git, but accidentally deleted a file. Now I'm lost 在Git Bash中意外创建了无法删除,修改,读取或移动的文件(Windows 10)。 我如何摆脱它? - Accidentally created a file in Git Bash with touch that can't be deleted, modified, read, or moved (Windows 10). How do I get rid of it? 如何知道文件是否已在bash中删除和创建? - How to know if file is deleted and created in bash? 如何检查文件是否已创建/删除/更改(Bash) - How to check if a file is created/deleted/changed (Bash) 我如何调整这个 git 日志命令 / bash 脚本以包括 git reflog 仍然应该知道的已删除分支的已删除提交? - How can I tweak this git log command / bash script to include deleted commits from deleted branches that git reflog should still know about? 如何获取echo以仅打印已删除的文件路径? - How to get echo to print only deleted file paths?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM