.gitignore 文件的用途,该文件只能作用于 Untracked Files,也就是那些从来没有被 Git 记录过的文件(自添加以后,从未 add 及 commit 过的文件)。
How to ignore files already managed with Git locally
方法一: git update-index
|
|
git ls-files shows all files managed by git.
-v check the file being ignored.
–skip-worktree is displayed with S
–skip-worktree 不会提交改动的文件了,但是切换分支的话 git 还是要抱怨你的 worktree 不够干净。此时可以用 git stash 来存取解决这个问题
方法二: git update-index (推荐,不用管是否切换分支
)
|
|
Also, since it is an idea to ignore local changes, git reset - hard command will delete local changes.
|
|