我有一个名为“style.css”的文件,git没有检测到它。如果我删除它也不检测它,但它确实检测我是否更改了文件的名称。但我需要这个名字。 该文件不在.gitignore文件中。这让我发疯了!
我将不胜感激。
答案 0 :(得分:70)
使用git check-ignore
命令调试gitignore文件(排除文件)。
例如:
$ git check-ignore -v config.php
.gitignore:2:src config.php
以上输出详细说明了每个给定路径名(包括行)的匹配模式(如果有)。
所以也许你的文件扩展名不会被忽略,而是整个目录。
返回的格式为:
<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
或使用以下命令在user和repo文件夹中打印.gitignore
:
cat ~/.gitignore $(git rev-parse --show-toplevel)/.gitignore $(git rev-parse --show-toplevel)/.git/info/exclude
或者使用git add -f <path/file>
,允许添加其他被忽略的文件。
有关详细信息,请参阅:man gitignore
,man git-check-ignore
。
答案 1 :(得分:11)
该文件也可以列在.git/info/exclude
中,并且还可以选择core.excludesfile
选项。
答案 2 :(得分:6)
除了gitignore和其他地方检查忽略模式之外,请检查您是否运行了git update-index --assume-unchanged
或git update-index --skip-worktree
。如果是这样,请取消它们。
确保所关注文件的repo或parent中没有一些奇怪的东西,它有自己的.git
。
尝试克隆您的仓库,看看您是否在克隆的仓库中看到相同的内容。如果是这样,请尝试克隆到其他计算机/ VM并检查。这会让你知道哪里出了问题。
答案 3 :(得分:6)
另一个注意事项,可能是罕见的情况,但我有这个问题。我将一些已经绑定到repo的文件从一个目录移动到另一个目录,复制/粘贴样式。
随之而来的是.git文件夹,它阻止了git检测文件夹。
所以我的文件夹结构是这样的,即使为原始项目1设置了回购,git也没有检测到文件夹2:
--Original Project 1
--.git
--Folder 1
--Folder 2
--.git
--Many other files/folders
删除子.git文件夹解决了我的问题。
答案 4 :(得分:5)
我遇到了同样的问题(components/dashboard/js-dev/training/index.js
由于某些原因未被跟踪),所以我做了以下事情:
$ git check-ignore -v components/dashboard/js-dev/training/index.js
$ (gave me nothing)
$ git check-ignore -v components/dashboard/js-dev/training/
$ /Users/User/.config/git/ignore:23: components/dashboard/js-dev/training/
无论如何,我发现这很奇怪,所以我看了看这个文件/Users/User/.config/git/ignore
,这就是它的样子:
(this is line 1)
# Automatically created by GitHub for Mac
# To make edits, delete these initial comments, or else your changes may be lost!
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
事实证明第23行实际上是.com.apple.timemachine.donotpresent
和# Directories potentially created on remote AFP share
之间的那一行,换句话说,它是一条完全空行!
我尝试删除所有额外的换行符,因此我的文件看起来像这样:
# Automatically created by GitHub for Mac
# To make edits, delete these initial comments, or else your changes may be lost!
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
我运行git status
,我注意到它现在正在接收components/dashboard/js-dev/training/
。我运行git add components/dashboard/js-dev/training/
,一切正常。
希望这有助于某人 - 这个问题让我陷入了不必要的长时间。
答案 5 :(得分:2)
我有一个类似的问题并解决了它。
运行git add
命令时收到此错误消息:
The following paths are ignored by one of your .gitignore files:
<file>
Use -f if you really want to add them.
fatal: no files added
所以我尝试通过在-f
命令中添加git add
来强制Git为我解决问题。这通常会强制Git调整.gitignore
文件,然后您就可以看到所需的更改或有问题的设置。
在我的特定情况下,.gitignore
文件末尾的换行似乎有一些奇怪的问题。这里Git如何解决问题:
-RemoteSystemsTempFiles
+RemoteSystemsTempFiles
\ No newline at end of file
答案 6 :(得分:1)
额外注意,我遇到了这个问题,发现对文件的更改没有被添加到提交中。除了右键单击项目并执行以下操作外似乎没有任何作用:
团队&gt;高级&gt;不假设
答案 7 :(得分:1)
我也碰到了这个问题,这似乎是Eclipse的EGit插件的一个问题。就像@ user1655478在之前的评论中说的那样,在项目视图中选择项目,执行右键单击并选择“团队&gt;高级&gt;不假设未更改”为我解决了问题。
答案 8 :(得分:0)
如果您的项目是maven项目,请检查您是否更改了src文件或目标文件。这就是我最近所做的。由于文件路径引用太长,我没有注意到路径中的“目标”。痛苦1小时后一切都好。
答案 9 :(得分:0)
我遇到了另一个原因。可能非常罕见的情况。
我将整个存储库复制到另一个文件夹来处理它。我对子模块所做的更改并没有被git检测到。原来,子模块文件夹中的.git文件包含对原始副本的绝对文件引用。一旦我更正了文件引用以指向我的工作副本,一切都很顺利。
答案 10 :(得分:0)
答案 11 :(得分:0)
这是我在刚创建的名为“ am”的分支上工作时发生的。我在另一个开发站上,看不到我添加到分支的文件。为了查看文件,我运行了以下命令
git checkout am
git branch --set-upstream-to=origin/am
git pull
拉动之后,所有更改都消失了
答案 12 :(得分:0)
首先检查git存储库中的文件,以确保该文件不存在,有时大写字母会弄乱被识别的文件,但不会被识别为更改,尤其是在.JPG之类的文件扩展名中>
(出于某种原因,这发生在我身上,尽管该文件与其他文件保存的方式相同,但扩展名仅大写,而不会出现在网站上)
'如果'这是问题,请检查相关文件夹中的“显示文件扩展名”,将文件重命名为其他具有小写扩展名的文件,git add和commit,然后将其重命名为最初想要的但保留小写扩展名,因为更明显的变化将被重写且不会被忽略
答案 13 :(得分:0)
此问题的另一个原因可能是+------------+-----------+-----+
|customer_id | ship_date | rank|
+------------+-----------+-----+
| sam | 8/20/2019 | 1 |
| sam | 9/20/2019 | 2 |
| sam | 9/23/2019 | 3 |
| tim | 9/20/2019 | 1 |
| tim | 10/18/2019| 2 |
+------------+-----------+-----+
文件。
就我而言,它是由.gitignore_global
应用自动生成的,而我却忽略了文件。它在我的用户路径(Sourcetree
)中。
答案 14 :(得分:0)
在我的情况下,我检查了.gitignore_global,发现所有的swift文件都被忽略了,我只删除了* .swift行,而git识别了我的文件。
答案 15 :(得分:-1)
退出GitHub应用程序对我有用。
症状:
我的回购是谷歌文件流。我只能在运行git status
时看到已修改的文件,但GitHub应用程序显示所有更改。