Git .gitignore without ignoring previously tracked files

I have an android studio project (imported from eclipse). After I imported into Andorid, I made the initial commit and forgot to add a new .gitignore file for the Android Studio framework.

Now git will not ignore assembly files, .gradle, etc.

I tried

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

but still, when I write git status, all files are displayed as deleted, and in github they are displayed as modified.

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 still see all the files in the build folders and .gradle, etc.

Any suggestions?

+1
source share
3 answers
  • git rm --cached "xxx"
  • git commit -m ""
  • git reset HEAD -- "xxx"
  • git commit -m "" (for updating repo)
+2
source

git clean -xf removes all files matching .gitignore.

+7
source

You might need to use this syntax:

**/build

0
source

Source: https://habr.com/ru/post/1246694/


All Articles