.gitignore 被 Git 忽略 [英] .gitignore is ignored by Git

查看:40
本文介绍了.gitignore 被 Git 忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My .gitignore file seems to be being ignored by Git - could the .gitignore file be corrupt? Which file format, locale or culture does Git expect?

我的.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/ 不会出现在未跟踪文件列表中.

I would like debug.log and nbproject/ not to appear in the untracked files list.

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

Where should I start looking to fix this?

推荐答案

即使到目前为止你还没有跟踪过文件,Git 似乎也能知道"甚至在你将它们添加到 .gitignore 之后.

Even if you haven't tracked the files so far, Git seems to be able to "know" about them even after you add them to .gitignore.

警告:首先提交或隐藏您当前的更改,否则您将丢失它们.

WARNING: First commit or stash your current changes, or you will lose them.

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

Then run the following commands from the top folder of your Git repository:

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

这篇关于.gitignore 被 Git 忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆