Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git .gitignore not working with log files

Tags:

git

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
like image 802
Edgaras Karka Avatar asked Apr 14 '16 08:04

Edgaras Karka


2 Answers

.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.

like image 135
Konrad 'Zegis' Avatar answered Sep 17 '22 06:09

Konrad 'Zegis'


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
like image 30
jkrcma Avatar answered Sep 20 '22 06:09

jkrcma