是否可以使用regular expressions,例如<script>
$(document).ready(function(){
$(window).scroll(function () {
$('#bar').css('top', $(document).scrollTop());
});
});
</script>
<style>
#bar {
position: relative;
}
</style>
#bar
{
width:900px;
height:40px;
display:inline-block;
}
<div id="bar"><input type="text" id="srch" name="srch"/></div>
?
我试过了,似乎只把它们解释为globs。我也厌倦了正则表达式旗帜:
git commit ".*my_file.*"
引发错误。
有没有人知道将正则表达式与Git命令结合的方法?
答案 0 :(得分:1)
不是Git本身。 Git只接收从shell传递的文件列表,因此由shell来对文件进行正则表达式匹配。我不认为bash可以做到这一点,但其他shell可能会这样做。
答案 1 :(得分:1)
我能想到的最好方法是使用find命令。例如,如果您只想要python文件:
find -type f -regex ".*\.py$" -exec git commit {} -m "committing only and all python files" \;
其他人可以想到一些不那么笨重的东西吗?
答案 2 :(得分:0)
正如mipadi所提到的,shell可以生成参数以生成git
的输入。
例如,ls
可以组合使用。让我们说我有一个带有以下文件的git init-ed目录:
.git/
my_new_project_file.py
my_older_project_file.py
some_other_file.py
我想添加除some_other_file.py
之外的所有内容。要做到这一点:
ls my*project*.py | xargs git add
检查我的git status
会显示my_new_project_file.py
和my_older_project_file.py
已上演,而some_other_file.py
已被忽略。
n.b。 ls
不支持正则表达式;只是全球化。
答案 3 :(得分:0)
正如Candic3所指出的,git
支持glob:
git add *my_file*