2

The Problem

I had a lot of files autogenerated by Android studio after I build the project, so when I try to commit the project, the commit section is full of files I didn't want to commit or push to the repo.

enter image description here

How I can tell Git to don't care about these files and didn't commit or push them?

What I try

I try to add the packages dir in the .gitignor file, but it seems nothing happens.

enter image description here

Aiman Alyosofi
  • 625
  • 1
  • 13
  • 1
    Does this answer your question? [How can I make Git "forget" about a file that was tracked, but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-can-i-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitign) – 1615903 Jun 28 '22 at 09:52

1 Answers1

1

While a git rm --cached -r -- *.dex should be enough, don't forget it will only delete those files from the current commit.

If they are big, and should never have been committed, you would need to remove them from the full history of commits (assuming you are the only one working on this repository, or assuming you can warn your colleague about the impending git push --force)

Using newren/git-filter-repo

cd repo
git filter-repo --path-glob '*.dex' --invert-paths

Again, if those files are small, and with a limited history, a simple git rm --cached is enough.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250