git - 即使在更新 git index 之后,git status 也会显示已删除的文件
问题描述
我已经克隆了一个 git repo。在构建过程中,某个文件夹中的许多文件显示为在执行时被删除:git status。
他们已经在我不想删除的远程仓库中。关于这一点,我浏览了以下帖子: Git ignore deleted files
之后,我也将目录放入 .gitignore 中。仍然在执行git status时,我可以看到相同的结果。
解决方案
在本地删除文件而不是在本地删除remote
这不会长期有效。当其他人克隆您的存储库时,他们将获得文件。
恢复本地文件
>git checkout .
将恢复已删除的文件。
/mnt/c/git/repo666 (branchX)>git status
On branch branchX
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: a.txt
no changes added to commit (use "git add" and/or "git commit -a")
/mnt/c/git/repo666 (branchX)>git checkout .
/mnt/c/git/repo666 (branchX)>git status
On branch branchX
nothing to commit, working tree clean
/mnt/c/git/repo666 (branchX)>
推荐阅读
- python - 如何获取图像文件名并将其发送到flask中的特征提取过程?
- html - 带引导带的偏移和中心容器
- css - 为什么 webpack 会以如此奇怪的方式处理 CSS?
- python - Google Santa Tracking Api 中圣诞老人当前位置的变量是什么?
- python - 使用 Python 请求发出自定义请求
- tensorflow - pytorch 中的 tf.function 属性
- flutter - 使用颤振共享偏好以节省颜色
- java - 如何从私有 int 返回 void?
- prolog - 将子句的其余部分作为列表获取并创建列表列表
- r - 如何模拟rest API的http响应?