gpt4 book ai didi

git - .gitignore 不会停止在文件中跟踪更改

转载 作者:IT王子 更新时间:2023-10-29 00:34:31 25 4
gpt4 key购买 nike

我对 .gitignore 中的文件所做的更改正在被 git 跟踪。

文件结构:

.gitignore
wp-config.php

.gitignore 的内容:

wp-config.php

当我更改 wp-config.php,然后运行 ​​git status 时,我看到它已被修改:

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 中就足够了。

最佳答案

使用 .gitignore,只有未跟踪的文件会被忽略。

添加文件后,不会忽略对该文件的更改。

在这种情况下,您应该改用assume-unchangedskip-worktree

git update-index --assume-unchanged -- wp-config.php

git update-index --skip-worktree -- wp-config.php

关于git - .gitignore 不会停止在文件中跟踪更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14513854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com