Can git ignore specific commented debug code? [duplicate]
Domanda
As a front end developer, I frequently add code to hide backend devs' error messages ;)
Is there a way of getting git to ignore code commented in a certain way? eg
.error { display:none; } // DEBUG-GIT-PLEASE-IGNORE
Or has someone written a plugin for this?
Soluzione
You can create a clean filter, which drops all lines containing DEBUG-GIT-PLEASE-IGNORE
.
But a more clean way is to change the web application, so that this behavior can be configured on the web host.
Altri suggerimenti
Essentially, no. Git does not currently have a way to ignore particular parts of a file, only whole files.
However, one could probably write a script to modify the output from git diff
, and configure git to use that script. I'm not sure how effective that would be, as I don't think git uses the diff to stage files, but it may be worth researching.