【问题标题】:git grep for less than or greater than character (in Windows shell)git grep 用于小于或大于字符(在 Windows shell 中)
【发布时间】:2014-01-20 22:40:49
【问题描述】:

我正在尝试在 git 存储库中 grep 单词 <template>

我该如何为此写我的git grep 声明? (Shell 似乎假设 作为重定向参数)

(看起来这是特定于从 cmd 会话运行的 git for windows。Git Bash 工作正常)

【问题讨论】:

    标签: git cmd escaping windows-shell msysgit


    【解决方案1】:

    使用 Git Bash,您应该能够简单地引用它:git grep "<template>"...

    通过 Windows 的 cmd.exe 运行 Git 有点不同。在那里,git grep ^<template^> ... 应该可以工作。这是因为cmd.exe 使用^ 作为其转义字符(而不是\,后者用于Bash、ZSH 和几乎所有其他shell)。

    另见this question

    【讨论】:

    • 请注意,这是您处理任何 shell 引用的方式,而不仅仅是 git
    • 我现在正在运行 git for windows 并执行 git grep "
    • @Nocturne 您使用的是 Git Bash 还是 Windows shell?如果是后者,请尝试git grep "\<template\>"。如果是前者,这个答案指定的内容应该按原样工作。
    • @CharlesDuffy Git Bash 似乎工作正常。问题似乎出在 Windows shell 上。 git grep "\<template\>" 失败并出现错误 The syntax of the command is incorrect.
    • ...是的;关于 Windows Shell 的问题可能应该被标记为 cmd.exe 问题,而不是关于 git 的任何问题;大多数了解 git 的人,包括我自己,都更熟悉 unixy 平台。
    猜你喜欢
    • 2011-01-25
    • 2022-01-12
    • 1970-01-01
    • 2018-08-29
    • 2017-08-30
    • 1970-01-01
    • 2013-09-02
    • 1970-01-01
    相关资源
    最近更新 更多