笔者在编写Z Shell文件的时候经常会使用到set -x来开启调试,但不希望提交到仓库

解决方案

Git提供了一种文件过滤器,此方法可以帮助在提交时移除set -x
我们先来编写脚本,如何移除这一行。
即使用sed "/^set -x$/d"

给过滤器起一个名字,这里以“DebugShell”为例。添加过滤器

git config --local filter.DebugShell.clean 'sed "/^set -x$/d"'
git config --local filter.DebugShell. smudge 'sed "/^set -x$/d"'

修改.gitattributes文件,对特定文件使用过滤器。

*.zsh filter=DebugShell

相关文章:

  • 2021-07-08
  • 2021-06-02
  • 2021-06-06
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-15
  • 2022-02-14
  • 2022-12-23
  • 2022-02-07
  • 2021-10-30
  • 2022-12-23
相关资源
相似解决方案