git .gitignore不会忽略以前跟踪的文件 [英] git .gitignore not ignoring previously tracked files

查看:311
本文介绍了git .gitignore不会忽略以前跟踪的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android工作室项目(从eclipse导入)。在我完成向Andorid工作室的导入之后,我做了一个初始提交并忘记为Android Studio的结构添加新的.gitignore文件。

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.

现在git不会忽略构建,.gradle等文件。

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

我试过了 p>

I have tried the

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

所有文件都显示为已删除,并在github中显示为已更改。

trick but still when I write git status all files appear as deleted and in github they appear as changed.

以下是我的.gitignore

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.

有什么建议?

推荐答案


  1. git rm --cachedxxx
  2. git commit -m
  3. git reset HEAD - xxx

  4. git commit -m(更新回购)
  1. git rm --cached "xxx"
  2. git commit -m ""
  3. git reset HEAD -- "xxx"
  4. git commit -m "" (to update repo)

这篇关于git .gitignore不会忽略以前跟踪的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆