I
I
inavo2020-04-15 10:28:05
git
inavo, 2020-04-15 10:28:05

Is it possible to add single lines to gitignore?

When working, sometimes you have to use wardumps, console logs, etc. With intermediate commits, you have to delete all unnecessary lines, and then return them if they are still needed, which actually tires, and sometimes you forget to remove some.

Therefore, I wonder if it is possible to exclude individual lines from commits?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Romanov, 2020-04-15
@inavo

Create your own log or vardump function that echo data only in development

mylog function(data) {
    if(getEnv("APP_ENV") == 'dev') {
        console.log(data)
    }
}

It's just an idea, the function can be complex. It can write to a file, or to the console. Or when developing to the console, and in production to a file.
Good code should be well logged. So there is no need to remove it. While your application is under development, all logs and dumps will be visible. Or maybe not. A good logger has levels. For example, if you are at the debug level, you will see all dumps and logs, if you are at the information level, then only logs, etc.
One variable can then switch what to show and what not. For example, you need to debug a piece of code that was not written by you. What to do? Arrange logs again, then delete? No, just switch to logger mode and you can see everything.

A
alternativshik, 2020-04-15
@alternativshik

Well, as an option, some kind of pre-commit hook that will clean up files before committing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question