How to tell git to ignore individual lines, i.e. gitignore for specific lines of code [duplicate]
问题 This question already has an answer here: Can git ignore a specific line? 8 answers .gitignore can ignore whole files, but is there a way to ignore specific lines of code while coding? I frequently and repeatedly add the same debug lines in a project, only to have to remember to remove them before committing. I\'d like to just keep the lines in the code and have git disregard them. 回答1: This is how you can kind of do it with git filters: Create/Open gitattributes file: <project root>/