【发布时间】:2012-07-12 04:27:16
【问题描述】:
我的 .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.log 和nbproject/ 不会出现在未跟踪的文件列表中。
我应该从哪里着手解决这个问题?
【问题讨论】:
-
确保您的
.gitignore文件使用ANSI或UTF-8编码。如果它使用Unicode BOM之类的其他内容,Git 可能无法读取该文件。 -
@ADTC 这正是我的机器(Windows)上的问题。我在 PowerShell 中使用了
echo "file" > .gitignore,该文件具有 UCS-2 编码! -
git rm --cached debug.log nbproject/ -
为什么这里的第一条评论不是答案是我无法理解的
-
@MattParkins 啊,我现在看到了,我仍然感到惊讶,这样一个简单而中肯的答案被埋在评论中,或者实际接受的答案就在那里。谢谢!