Dims
Dims

Reputation: 50989

How to remove files from under Git control?

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?

Upvotes: 0

Views: 61

Answers (2)

GyulaWeber
GyulaWeber

Reputation: 64

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/

Upvotes: 0

Nick Rameau
Nick Rameau

Reputation: 1318

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

Upvotes: 1

Related Questions