参考:https://stackoverflow.com/questions/936249/how-to-stop-tracking-and-ignore-changes-to-a-file-in-git
有三种方式
- 直接从.git删除
git rm --cached <file-name> or git rm -r --cached <folder-name>
.git不会再记录该文件,只有本地会保留。
- .git不再记录更改,pull会覆盖当前文件/目录
git update-index --assume-unchanged <path-name>
告诉git某个文件或目录是不改变的,git status就不会显示对应的修改,但是pull会覆盖这个文件或目录。
- .git不再记录更改,pull不会覆盖当前文件/目录,本地保留一个独立的版本
git update-index --skip-worktree <path-name>
恢复.git的跟踪
git update-index --no-skip-worktree path/to/file