.gitignore不会停止跟踪文件中的更改 [英] .gitignore doesn't stop changes being tracked in files
本文介绍了.gitignore不会停止跟踪文件中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 .gitignore
内的文件所做的更改被git跟踪。
Changes I make to a file that's within my .gitignore
are being tracked by git.
文件结构:
.gitignore
wp-config.php
.gitignore
的内容:
wp-config.php
当我更改 wp-config.php
,然后运行 git status
我看到它已被修改:
When I change wp-config.php
, and then run git status
I see that it has been modified:
alex$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: wp-config.php
#
如何停止跟踪此文件?我认为将其放入 .gitignore
就足够了。
How to I stop tracking this file? I thought putting it in .gitignore
would be enough.
推荐答案
.gitignore
,仅忽略未跟踪的文件。
With .gitignore
, only untracked files are ignored.
添加文件后,不会更改该文件
Once the file has been added, change to that file are not ignored.
在这种情况下,您应该使用假定不变或
skip-worktree
In this case, you should use assume-unchanged
or skip-worktree
instead.
git update-index --assume-unchanged -- wp-config.php
或
git update-index --skip-worktree -- wp-config.php
这篇关于.gitignore不会停止跟踪文件中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文