git。gitignore没有忽视先前跟踪文件 - git .gitignore not ignoring previously tracked files

- 此内容更新于:2016-02-03
主题:

我有一个Android工作室项目(进口从eclipse)。并导入Andorid工作室后我做了一个初步提交和忘了添加新的。gitignore文件为Android工作室的结构。现在git不会忽视构建。gradle文件等。我试过诀窍,但仍然当我写git状态显示为所有文件删除,在github出现改变。下面是我的。gitignore我仍能看到我的构建和所有文件。gradle文件夹等。有什么建议吗?

原文:

I have an Android studio project (imported from 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.

Now git won't ignore the build, .gradle files etc.

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.

Below is my .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.

Any suggestions?

网友:>我仍能看到我的构建和所有文件。gradle文件夹等等。我不能完全理解这个问题。如果你不想看到文件,就删除它们(不仅从缓存):gitrm-r——缓存。同时,你有试过让git清洁df?:-)

(原文:>I can still see all files in my build and .gradle folders etc. I can't understand the question completely. If you don't want to see files - just delete them (not just from cache): git rm -r --cached . Also, have you tried make git clean -df ? :-))

楼主:我试着清洁dfgit。我的意思是:我做了rm命令,和现在。gitignore到位我希望他们不会再次出现,在git中地位,但是他们做……和github的应用程序显示一遍

(原文:I tried git clean -df. What I mean is that: I did the rm command, and now that the .gitignore is in place I would expect that in git status they would not appear again, but they do... And github's app shows them again)

网友:对不起。你可以用我下面描述:-)希望它能有所帮助。

(原文:Sorry. You can just use git clean -xf as I described below :-) Hope It'll help.)

解决方案:
gitcommit-m”(更新回购)
原文:
  1. git rm --cached "xxx"
  2. git commit -m ""
  3. git reset HEAD -- "xxx"
  4. git commit -m "" (to update repo)
解决方案:
也许,你需要使用这个语法:
原文:

Perhaps, you need to use this syntax:

**/build

解决方案:
删除所有文件.gitignore相匹配。
原文:

git clean -xf removes all files that matches .gitignore.