0

I have occasionally added .class files under Git control. Now I have headaches. Each push I am obliged to manually remove files from list and each pull it warns me to stash chenged files.

How to completely remove some files from under Git?

Dims
  • 47,675
  • 117
  • 331
  • 600
  • Possible duplicate of [Stop tracking and ignore changes to a file in Git](http://stackoverflow.com/questions/936249/stop-tracking-and-ignore-changes-to-a-file-in-git) – sergej Nov 14 '16 at 20:35

2 Answers2

1

You use .gitignore

Create a .gitignore file in your root directory (don't forget the period in front) and add the name of the files you want git to ignore in it:

*.class
Nick Rameau
  • 1,258
  • 14
  • 23
0

Before you begin experimenting with your valuable code, I suggest to create a backup first.

First, you should tell git to ignore those files in the future, by writing *.class into the .gitignore file.

The next thing is, to tell git to not track those files anymore, by git rm --cached <file>

If you've pushed something sensitive, and want to remove the history from the repository, follow the github documentation about this topic: https://help.github.com/articles/remove-sensitive-data/

GyulaWeber
  • 64
  • 4