[英].gitignore is ignored by Git
我的.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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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
文件似乎被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/
不会出现在未跟踪的文件列表中。
我应该从哪里着手解决此问题?
每当我遇到 git 正在跟踪.gitignore
列出的文件的情况时,我使用以下内容:
git update-index --skip-worktree <file_name>
我的.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
文件似乎被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
文件似乎被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/
不会出现在未跟踪的文件列表中。
我应该从哪里着手解决此问题?
看到有几个人已经回答过了,不知道有没有说清楚。 就我而言,问题是使用 echo 命令创建 .gitignore 文件。 在这种情况下,文件编码已更改,我必须打开文本文件,单击另存为并将底部选项卡中的编码更改为 UTF-8。 当使用 touch 命令创建文件并通过文本编辑器编辑其内容时,.gitignore 没有出现问题。
这里有很多答案,但对我有用的并不完全适用于任何特定的答案,我正在以一种简单的方式一一记下需要在这里完成的所有步骤:
Pre --- 备份 repo 以防万一。 (我没有,但可能会让你感觉更安全)
这可能听起来很傻,但什么解决我的问题是认识到.gitignore
正常工作,即使它说deleted: yourfile
上git的状态。
我打算忽略一个错误日志文件,忽略我造成的任何错误,但保存其他开发人员造成的错误,以防有一天他们在调试一个奇怪的问题时派上用场。 但是,git 不会让您“忽略”并同时保留文件。
我希望它“及时冻结”,但 git 说它要么被跟踪,要么根本不允许在那里。
PhpStorm(可能还有其他一些 IDE 用户) ,就我而言,问题是我通过查找器在项目外创建并添加了文件。
我删除了那个,然后在 PhpStorm 项目中重新创建了相同的一个,右键单击 -> 新建 -> 文件,它立即生效。
我的 30 美分技巧:
git clean -f
(我试过git rm -r --cached .
但它对我不起作用。)警告: git clean -f 将删除未跟踪的文件,这意味着它们将永远消失,因为它们没有存储在存储库中。 在执行此操作之前,请确保您确实要删除所有未跟踪的文件。
也许您可以尝试git clean -xdf
删除被忽略的目录和未跟踪的文件
HEAD
带到当前位置git reset HEAD --hard
。 检查git status
。
现在创建.gitignore
在我的情况下想要忽略名为data
的文件夹。 所以我写了/data/
(最初的/
用于文件/文件夹,后来的/
仅用于文件夹)。
尽管在这篇文章和其他文章中尝试了各种建议(例如Gitignore 不工作和gitignore 不工作 - 被忽略? )我无法让 git 忽略我的 .gitignore.txt 文件中包含的文件/文件夹。
在尝试了创建 .gitignore.txt 文件的不同方法后,我设法弄清楚如何让它工作,尽管我不能说我理解为什么.gitignore.txt 。 知道是否有人可以提供解释会很有趣。
为了那些也可能发现以前的答案没有解决他们的问题的人的利益,我将描述我尝试过的方法、无效的方法以及有效的方法。 希望这样做也可以阐明原因。 请注意,我使用的是 Windows 10。
尝试 #1(失败)
在 Windows 资源管理器中创建新的 txt 文件:
我运行git status
但我想忽略的文件/文件夹显示为未跟踪。 我在 Windows 资源管理器中检查了文件属性。 正如预期的那样,文件名是“.gitignore”,文件类型是“文本文档( .txt )”。
注 1 :
一些贡献者表示编码必须是 ANSI(而不是 UTF)。 在 Notepad++ 中,我发现无论我是否执行编码 -> ANSI 或编码 -> 转换为 ANSI + 保存,关闭文件并重新打开它(在 Notepad++ 中),当我检查编码时,它总是报告 UTF- 8. 最终工作的 .gitignore.txt 文件也是如此。
尝试#2(失败)
在 Notepad++ 中创建新的 txt 文件:
我运行git status
并且和以前一样,所有文件/目录都列在未跟踪的文件下。 和以前一样,文件名是“.gitignore”,文件类型是“文本文档( .txt )”。
尝试#3(成功)
在 Notepad++ 中仍然打开相同的文件 (.gitignore.txt):
我注意到创建的文件在 Windows 资源管理器中似乎没有名称。 我检查了文件的属性:文件名字段为空,文件类型为“文本文档( .gitignore )”。
我运行git status
,这次我想忽略的文件/文件夹没有列为未跟踪文件 -成功!
在 Notepad++ 中打开文件我注意到编码是 UTF-8,并且文件名被标识为“.gitignore”(与 Windows 资源管理器中不同)。
因此,创建 txt 文件的方式似乎有些微妙。 也许这是 Windows 独有的特性?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.