Skip to content

Instantly share code, notes, and snippets.

@zthxxx
Last active November 8, 2020 07:50
Show Gist options
  • Save zthxxx/153bdcc241300b0adc666f0b3222af85 to your computer and use it in GitHub Desktop.
Save zthxxx/153bdcc241300b0adc666f0b3222af85 to your computer and use it in GitHub Desktop.
auto ignore console.log at git diff or stage
# .gitattributes or .git/info/attributes
# https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreattributesFile
*.[jt]s filter=ignoreLogStage
*.[jt]sx filter=ignoreLogStage
# https://git-scm.com/docs/gitattributes
# enable this config via the command below
# git config include.path ../.gitconfig
# https://stackoverflow.com/questions/6557467/can-git-ignore-a-specific-line/16244817#16244817
# git filter workflow: https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion
[filter "ignoreLogStage"]
# set `*.[jt]s filter=ignoreLogStage` in .gitattributes
# ignore log code generated by https://github.com/Chakroun-Anas/turbo-console-log
# git config filter.ignoreLogStage.clean 'perl -ne "print unless /^[\t ]*\/* ?console\.log\(.TCL: /"'
clean = perl -ne \"print unless /^[\\t ]*\\/* ?console\\.log\\(.TCL: /\"
smudge = cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment