git - .gitignore exclude specific file -
i trying use .gitignore
file exclude templates.js
located in public/app/
folder. .gitignore
file looks this:
/vendor /node_modules composer.phar composer.lock .ds_store templates.js
but when check in git gui, templates.js
file still show in it. how can exclude file using .gitignore
?
in contrast name "ignore" might suggest. .gitignore
consulted when git add
files: in other words file added (index of the) repository not excluded based on .gitignore
.
first better modify .gitignore
such file no longer added. add following line .gitignore
file:
public/app/template.js
next need exclude file repository. don't want remove file file system, can done with:
git rm --cached public/app/template.js
the --cached
flag ensures file not removed file system. (if not important, can use git rm public/app/template.js
, but remove file).
background
the reason .gitignore
not proactively used because might want override .gitignore
. instance don't want track *.log
files, can specify *.log
in .gitignore
. if there specific 1 want track can add git add -f some.log
. -f
flag forces git
add file.
Comments
Post a Comment