1、配置語法:
以斜杠“/”開頭表示目錄;
以星號“*”通配多個字符;
以問號“?”通配單個字符
以方括號“[]”包含單個字符的匹配列表;
以嘆號“!”表示不忽略(跟蹤)匹配到的文件或目錄;
此外,git 對於 .ignore 配置文件是按行從上到下進行規則匹配的,意味着如果前面的規則匹配的范圍更大,則后面的規則將不會生效;
2、示例:
(1)規則:fd1/*
說明:忽略目錄 fd1 下的全部內容;注意,不管是根目錄下的 /fd1/ 目錄,還是某個子目錄 /child/fd1/ 目錄,都會被忽略;
(2)規則:/fd1/*
說明:忽略根目錄下的 /fd1/ 目錄的全部內容;
(3)規則:
/*
!.gitignore
!/fw/bin/
!/fw/sf/
說明:忽略全部內容,但是不忽略 .gitignore 文件、根目錄下的 /fw/bin/ 和 /fw/sf/ 目錄;
這里給出一個Visual Studio 的igitignor實例供大家參考。
## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user *.sln.docstates # Build results [Dd]ebug/ [Rr]elease/ x64/ build/ [Bb]in/ [Oo]bj/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* *_i.c *_p.c *.ilk *.meta *.obj *.pch *.pdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.log *.scc # Visual C++ cache files ipch/ *.aps *.ncb *.opensdf *.sdf *.cachefile # Visual Studio profiler *.psess *.vsp *.vspx # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # NCrunch *.ncrunch* .*crunch*.local.xml # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.Publish.xml *.pubxml # NuGet Packages Directory # Enable nuget packages restore when building !packages/ packages/* !packages/repositories.config # Windows Azure Build Output csx *.build.csdef # Windows Store app package directory AppPackages/ # Others sql/ *.Cache ClientBin/ [Ss]tyle[Cc]op.* ~$* *~ *.dbmdl *.[Pp]ublish.xml *.pfx *.publishsettings # RIA/Silverlight projects Generated_Code/ #Visual Studio LightSwitch _Pvt_Extensions/ GeneratedArtifacts/ ServiceConfiguration.cscfg ModelManifest.xml generated.parameters.xml ## TODO: Comment the next line if you want version controls the generated client .xap file *.Client.xap # Backup & report files from converting an old project file to a newer # Visual Studio version. Backup files are not needed, because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm # SQL Server files App_Data/*.mdf App_Data/*.ldf # ========================= # Windows detritus # ========================= # Windows image file caches Thumbs.db ehthumbs.db # Folder config file Desktop.ini # Recycle Bin used on file shares $RECYCLE.BIN/ # Mac crap .DS_Store # VisualStudioCode .vscode