git gitignore - 致命:未添加文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12084227/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:24:06  来源:igfitidea点击:

gitignore - fatal: no files added

git

提问by Sig

I have an issue with git, more precisely with gitignore.

我有一个 git 问题,更准确地说是 gitignore。

I have created an empty folder Initialized git

我创建了一个空文件夹 Initialized git

mkdir fold
cd fold
git init

Updated gitignore (as below)

更新了 gitignore(如下)

 *.prjx

Committed gitignore

提交 gitignore

git add .gitignore
git commit -m "update gitignore"

Now I have several files (among them a .prjx) and folders in my root (fold) and I'd like to add all of them, but when I run

现在我的根目录(折叠)中有几个文件(其中包括 .prjx)和文件夹,我想添加所有这些文件,但是当我运行时

git add *

I get the message below

我收到下面的消息

The following paths are ignored by one of your .gitignore files:
ftc.prjx
Use -f if you really want to add them.
fatal: no files added

I don't want to add it, I simply want add all the other files and folders. From my understanding .gitignore should handle exactly that so why I get the message above? Am I missing something?

我不想添加它,我只想添加所有其他文件和文件夹。根据我的理解 .gitignore 应该完全处理,所以为什么我会收到上面的消息?我错过了什么吗?

回答by Olivier Refalo

you should run git add .rather than git add *

你应该跑git add .而不是git add *

the *is interpreted by the shell and substituted with all file and folder in the current location. obviously ftc.prjxis one of them and git is just warning that the file is in the ignorelist.

*是由shell解释,并与所有文件和文件夹中的当前位置被取代。显然ftc.prjx是其中之一,而 git 只是警告该文件在忽略列表中。