参考: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
本文介绍了在Git中停止跟踪文件或目录的三种方法:使用`git rm --cached`删除文件,`git update-index --assume-unchanged`忽略更改,以及`git update-index --skip-worktree`保持本地独立版本。这些操作将影响git status的显示和pull的行为。
896





