warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behaviour will change in Git 2.0 with respect to paths you removed.
Paths like 'usr/plugins/AdminBeautify/assets/AdminBeautify.min.v2.1.43.js' that are
removed from your working tree are ignored with this version of Git.
- 'git add --ignore-removal
', which is the current default,
ignores paths you removed from your working tree. - 'git add --all
' will let you also record the removals.
Run 'git status' to check the paths you removed from your working tree.
这是个警告,不是错误,命令已经执行了。但你可能没达到预期效果,解释一下:
原因:你这台 CentOS 上的 git 版本还是 1.x。旧版 git add . 的默认行为是忽略已删除的文件——也就是说,你工作区里被删掉的文件(比如那个 AdminBeautify.min.v2.1.43.js)不会被记录为“删除”,暂存区里还留着它。
Git 2.0 开始 git add . 才默认等同于 git add -A,这条警告就是在提前提醒你。
解决方法:改用:
bash
git add -A这样新增、修改、删除三种变化都会被暂存。然后 git status 确认一下,删除的文件应该显示为 deleted: 状态。
顺便提醒:服务器上出现“工作区文件被删除”的情况,结合你本地刚做的 git rm --cached 操作,我猜你的流程可能是:本地提交删除 → 服务器拉取。如果服务器上那些“被删除的文件”其实是你想保留的本地文件,用 git add -A 提交删除就真的没了,操作前先用 git status 看清楚哪些文件是删除状态,确认无误再提交。
评论 (0)