Gar*_*rwe 18
patchutils有一个grepdiff可用于实现此目的的命令.
# check that the regex search correctly matches the changes you want.
git diff -U0 | grepdiff 'regex search' --output-matching=hunk
# then apply the changes to the index
git diff -U0 | grepdiff 'regex search' --output-matching=hunk | git apply --cached --unidiff-zero
Run Code Online (Sandbox Code Playgroud)
我-U0在diff上使用以避免获得无关的更改.您可能希望调整此值以适应您的情况.
RDL*_*RDL -1
xargs 就是您要寻找的。尝试这个:
grep -irl 'regex_term_to_find' * | xargs -I FILE git add FILE
Run Code Online (Sandbox Code Playgroud)
管道上方|是用于搜索所有文件的标准 grep 命令*。选项有:
i- 不区分大小写r- 递归遍历目录l- 仅列出文件名xargs语句的一部分是FILE用于 grep 命令传递的每个参数/匹配的变量名称。然后在适当的情况下使用变量输入所需的命令。