English 中文(简体)
gitignore对档案进行排序前和次直辖区的体积
原标题:gitignore match files with pre and suffix in subdirectory

我只想追踪从“es”开始、到*.h或*.m的档案。

i 审判:

#exlude all
*
#except
!es*.h
!es*.m

以及

#exlude all
*
#except
!*/es*.h
!*/es*.m

但是,在子公司中,既没有处理档案

最佳回答

当你忽视所有事项时(*),你无视文件夹,即使文件内容也一样,因为*与一切相符。

如果你unignore,那只与根 d的files相匹配。 如果你需要编辑目录,你必须明确说(见<条码>!mydir/)。 但是,这将破坏该继承人的所有内容,因此,你必须重新界定该继承人内容的忽视/不主权模式。 即使你这样做,如果你已经把ir子添加到该指数中,那么你就在<代码>git status上 won。

Your case can be solved easily but inverting the pattern.
What you basically want to do is ignore everything that

  • does not start with es and
  • does not end with .h or .m.

因此:

$ ls -a
.  ..  .git  .gitignore  a  b  blah  c  ebar.m  esfoo.h  esfoo.m  sbar.m
$ ls -a blah/
.  ..  a  b  c  ebar.m  esfoo.h  esfoo.m  sbar.m
$ git status -s
?? blah/
?? esfoo.h
?? esfoo.m
$ git status -s blah/   # matching files ignored and also ignored on `git add`
?? blah/esfoo.h
?? blah/esfoo.m
$ git add .
$ git status -s         # only wanted files were added
A  blah/esfoo.h
A  blah/esfoo.m
A  esfoo.h
A  esfoo.m
$ cat .gitignore        # the ignore pattern -- ignore
[^e]*                   # everything that doesn t start with  e 
e[^s]*                  # and is not followed by an  s 
*.[^hm]                 # and does not end with  .h  or  .m 
!/blah                  # uningore the wanted subdirs

正如你在最后指挥中所看到的那样,我ve弃了你的规律,无视从<条码>开始、不随附<条码>、不随附<条码>、与<条码>相左的条码。 尽管继承人的内容更多,但随着其与模式相匹配而被忽视,只添加了被通缉的部分。

<<>edit>/em>:更新

问题回答

暂无回答




相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签