git - .gitignore 被 Git 忽略

标签 git gitignore

我的 .gitignore 文件似乎被 Git 忽略了 - .gitignore 文件是否已损坏? Git 期望哪种文件格式、语言环境或文化?

我的.gitignore:

# This is a comment
debug.log
nbproject/

git status 的输出:

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       debug.log
#       nbproject/
nothing added to commit but untracked files present (use "git add" to track)

我希望 debug.lognbproject/ 不出现在未跟踪的文件列表中。

我应该从哪里着手解决这个问题?

最佳答案

即使到目前为止您还没有跟踪这些文件,即使在您将它们添加到 .gitignore 之后,Git 似乎也能够“知道”它们。

警告:首先提交或存储您当前的更改,否则您将丢失它们。

然后从 Git 存储库的顶级文件夹运行以下命令:

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

关于git - .gitignore 被 Git 忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11451535/

相关文章:

Github 在等待 pull 请求时在 fork 上工作

linux - 将用户从 bitbucket 切换到 github

git - Git 中忽略目录的语法是什么?

asp.net-mvc - git 和 ASP MVC

docker - gcloud构建提交不更新文件

git - 如何对谷歌云 git repo 进行代码审查

git - 在 git log 的 --name-status list 中,状态标签后缀的数字是什么?

git - 如何重命名git根文件夹?

gitignore 不删除文件

git - Netbeans 和 Git,忽略 .obj 文件