在git中添加补丁,与文件中的正则表达式匹配的所有区块 [英] Add patch in git, all hunks matching regex in file
本文介绍了在git中添加补丁,与文件中的正则表达式匹配的所有区块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我可以使用/搜索给定的块,但只能找到第一。我想添加所有匹配项。
解决方案
不幸的是, 2011年7月的修补程序现在无处可去。
它会引入 git add --hunks = magic
选项。
现在,您将需要处理:
git stash pop
)
相当繁琐的过程。
Is there a way to add all hunks in a file matching a regex?
I know I can search for a given hunk with /, but that only finds the first. I want to add all matching.
解决方案
Sadly, the patch in July 2011 went nowhere for now.
It would have introduced a git add --hunks=magic
option.
For now, you will have to do with:
- extracting a patch based on your regexp: see "Filtering a diff with a regular expression"
- git stash your changes
- apply your patch and
git add
- reset your index and apply your stash (
git stash pop
)
Quite a cumbersome process.
这篇关于在git中添加补丁,与文件中的正则表达式匹配的所有区块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文