git update-index --skip-worktree
适用对象:已经被 Git 跟踪(tracked)的文件 该命令的作用是:让 Git 在本地忽略某些已跟踪文件的改动,但不改变仓库历史,也不影响他人。

1. 单个文件
git update-index --skip-worktree <file>
恢复跟踪:
git update-index --no-skip-worktree <file>
2. 某目录下多个文件
git ls-files <target-directory>|xargs git update-index --skip-worktree

多个文件错误写法:

- 不是 Git 语法是否展开取决于 shell,git update-index 不会递归处理目录
- 必须先通过 git ls-files 列出已跟踪文件
- 再逐个设置 skip-worktree 标志
恢复跟踪:
git ls-files <target-directory>|xargs git update-index --no-skip-worktree
3. 验证哪些文件被 skip
git ls-files -v | grep


