简体   繁体   English

git .gitignore不忽略以前跟踪的文件

[英]git .gitignore not ignoring previously tracked files

I have an Android studio project (imported from eclipse). 我有一个Android Studio项目(从Eclipse导入)。 After I did the import to Andorid studio I did an initial commit and forgot to add the new .gitignore file for Android Studio's structure. 在导入到Andorid studio后,我做了一次初次提交,却忘记为Android Studio的结构添加新的.gitignore文件。

Now git won't ignore the build, .gradle files etc. 现在git不会忽略构建,.gradle文件等。

I have tried the 我尝试了

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

trick but still when I write git status all files appear as deleted and in github they appear as changed. 技巧,但是当我写git status时,所有文件都显示为已删除,而在github中它们显示为已更改。

Below is my .gitignore 以下是我的.gitignore

.gradle
/local.properties
/.idea/workspace.xml
.DS_Store

# Created by http://gitignore.io

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

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

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

# Eclipse project files
.classpath
.project    

# Proguard folder generated by Eclipse
proguard/

# Proguard folder generated by Intellij
proguard_logs/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

adt-bundle-windows-x86_64/

### Linux ###
.*
!.gitignore
!.git*
*~


### IntelliJ ###
*.iml
*.ipr
*.iws
.idea/

### Gradle ###
# Exclude Folder List #
.gradle/
build/

/*/out
/*/*/build
/*/*/production
*.iws
*.ipr
*~
*.swp

I can still see all files in my build and .gradle folders etc. 我仍然可以在build和.gradle文件夹中看到所有文件。

Any suggestions? 有什么建议么?

git clean -xf删除所有与.gitignore匹配的文件。

  1. git rm --cached "xxx"
  2. git commit -m ""
  3. git reset HEAD -- "xxx"
  4. git commit -m "" (更新仓库)

也许,您需要使用以下语法:

**/build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gitignore 不会忽略 Android 库中的一些构建文件 - Gitignore not ignoring some build files in Android library 适用于Ubuntu 14.04上Android Studio的.gitignore不会忽略某些文件。 [尝试了通常的解决方案] - .gitignore for Android Studio on Ubuntu 14.04 not ignoring certain files. [tried the usual solutions] Gitignore没有忽略某些project.properties - Gitignore not ignoring certain project.properties 即使我添加了build / to .gitignore,Git也不会忽略/ build / intermediates / files - Git wont ignore /build/intermediates/ files even though I added build/ to .gitignore Android Studio Git .gitignore vs 项目 > 设置 > 版本控制 > 忽略的文件 - Android Studio Git .gitignore vs Project > Settings > Version Control > Ignored Files Eclipse Git gitignore文件被忽略 - Eclipse Git gitignore file is ignored 为什么Android Studio忽略git repo中的文件以及如何从git导入项目? - Why Android Studio is ignoring files in git repo and how to import a project from git? Git:对于这种存储库,应将什么写入.gitignore文件? - Git: what to write into .gitignore file for this kind of repository? Git 忽略不在 .gitignore、exclude 或 config 文件中的目录 - Git ignores directory that is not in .gitignore, exclude or config file 统一。 Package 签名与之前安装的版本不匹配; 无视 - Unity. Package signatures do not match previously installed version; ignoring
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM