git添加与模式不匹配的文件
在Git中,将文件添加到提交中时,我们可以添加所有与模式匹配的文件,如下所示:
In Git, while adding files to a commit, we can add all files matching a pattern like so:
git add ** Component **
我发现此功能非常有用,可以快速添加许多具有相似名称的文件.
I find this feature pretty useful to quickly add lots of files with similar names.
例如,如果我的所有文件都基于组件命名,那么我可以快速将对组件所做的所有更改添加到组件中.
For example, If all my files are named based on components, then I can add all changes I did to a component quickly.
类似地,git中是否可以添加所有文件以提交排除匹配模式的文件?
Similarly, is there a way in git to add all files to commit excluding files matching a pattern?
类似的东西:
git add * .java --exclude ** Component1 **
这样我就可以对我的所有java文件进行更改,除了对component1的文件所做的更改之外?
So that I can all my java file changes except the changes that I made to the files of component1?
尝试以下方法之一
git add *.java ':(exclude):**Component1**'
git add *.java ':!**Component1**'
任何以冒号开头的pathspec都是魔术路径规范. exclude
是其中之一.
Any pathspec beginning with a colon is a magic pathspec. exclude
is one of them.