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

查看:118
本文介绍了.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天全站免登陆