Edgaras Karka
Edgaras Karka

Reputation: 7852

Git .gitignore not working with log files

I have git repository on /var/www/html/projectx. My goal is to tell git ignore two files /var/www/html/projectx/error.log and /var/www/html/projectx/requsets.log.

I try add .gitignore file

[git@x]$ cd /var/www/html/projectx
[git@x projectx]$ nano .gitignore

.gitignore :

*~
*.log

Upvotes: 10

Views: 9637

Answers (2)

Konrad 'Zegis'
Konrad 'Zegis'

Reputation: 16491

.gitignore file won't affect files that are already tracked. You can remove them with:

git rm --cached [file]

command. If you want only to ignore it locally you may try make it ignored by:

git update-index --assume-unchanged [file]

Or create explicit repository rules by editing .git/info/exclude file inside your repository. That's good way to ignore files that you generate but don't expect other users of repository to generate. Some details can be found here.

Upvotes: 28

jkrcma
jkrcma

Reputation: 1202

If you have already added these files into your Git repository, .gitignore would not have any effect until you remove them. Try:

git rm --cached error.log requsets.log

Upvotes: 10

Related Questions