我的 gitignore 不工作

My gitignore doesn't work

我试图为我找到解决方案,但我的 .gitignore 文件仍然不起作用

我明白了 this post,但对我没有帮助。

这是我的 gitignore 文件:

# Created by https://www.gitignore.io/api/android,macos

### Android ###
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries

# Keystore files
*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

### Android Patch ###
gen-external-apklibs

### macOS ###
*.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

但是当我重新制作时,我在 SourceTree 中看到了这个:

libraryProjectFolder/Build 文件夹中的所有文件 ()

Git 已经在跟踪这些文件,这就是您仍然看到它们的原因。

您应该在进行任何提交之前创建 .gitignore。

如果您想取消跟踪这些文件,可以参考following post。如果项目是新的,您可以创建一个新的存储库,复制您的文件并确保在进行第一次提交之前,您的新存储库中有 .gitignore 文件。

我有一种情况,我在 gitignore 上添加了一个文件,但出于某种我不知道的原因,它无法识别 gitignore 上的这个文件,并且仍然在我的工作区上显示它。要忽略此文件,我使用了以下命令:

git rm --cached myfile

希望以后能对大家有所帮助。

这对我有用。我不知道是什么原因。我修改了我的 gitignore 但总是出现我过滤的文件。 这就是我做的:

  • 我未跟踪不必要的文件-
  • 包括 gitignore 模式
  • 提交更改。

实际上我的存储库工作正常。