【问题标题】:How to remove a filter from Git如何从 Git 中删除过滤器
【发布时间】:2015-09-11 08:21:09
【问题描述】:

我想删除添加到 Git 的过滤器。命令git config --list 显示了我添加的过滤器

filter.spabs.clean=expand --initial -t 4
filter.spabs.smudge=expand --initial -t 4
filter.spabs.required

我怎样才能删除它? Git 在哪里存储过滤器?我已经验证了.gitconfig,但我没有.git/info/attributes 文件。

【问题讨论】:

  • 如果您的 ~/.gitconfig 文件中没有这些条目,请在您的 repo 的 .git/config 文件中查找它们;删除您想要的任何条目。
  • @Jubobs 我这样做了,但是当我这样做时得到了相同的结果git config --list
  • 您是否从.git/config 文件中删除了违规条目并保存了文件?
  • @Jubobs 是的,我删除了所有过滤器部分。
  • 正如弗雷德里克在他的回答中指出的那样,有问题的行可能在全局(即用户级)Git 配置文件中,通常是~/.gitconfig;运行git config --list --global 以检查它们是否确实在该文件中。或者它们可能在系统范围的 Git 配置文件中;运行git config --list --system 进行检查。

标签: git


【解决方案1】:

用于删除所有 config 文件(无需查找密钥):

git config --unset-all filter.spabs.clean
git config --unset-all filter.spabs.smudge
git config --unset-all filter.spabs.required

如“git credential.helper=cache never forgets the password?”所示,您可以这样做:

sudo git config --system --unset-all filter.spabs.clean
sudo git config --system --unset-all filter.spabs.smudge
sudo git config --system --unset-all filter.spabs.required

这将从/etc/gitconfig 中删除这些密钥。

【讨论】:

  • @user230137 你用的是什么git版本?在哪个操作系统上?
  • 包含这些命令的配置文件是/etc/gitconfig。 Ubuntu 14.04 上的 git 版本 1.9.1。我认为这是特权问题。
  • @user230137 好的。我已经相应地编辑了我的答案。
【解决方案2】:

所以你需要知道它们是在哪里定义的,而不是 git config --list 你可以运行 2 个命令

git config --local --list
git config --global --list

对于本地过滤器,您需要查看.git/config文件下

对于全局过滤器,您需要查看~/.gitconfig文件下

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    • 2016-11-18
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    • 1970-01-01
    • 2013-09-09
    相关资源
    最近更新 更多