Search code examples
gitgitignore

.gitignore - how to ignore file by matching start and end of name


I am using .gitignore for a C# solution and I'd like to ignore a file that's generated on build, to stop it getting checked in. The only consistent parts of the file name are the start and the end. Example:

Cloud.Core[.example1.example2.example3].xml

It always begins with "Cloud.Core" and ends with ".xml". It could have various connotations in between, such as:

  • Cloud.Core.xml
  • Cloud.Core.Example1.xml
  • Cloud.Core.Example2.Example2.xml

What mask should I add to my gitignore to bypass a file which has a start/end as described?

I've tried these and a few other variations with luck:

  • Cloud.Core*.xml
  • Cloud.Core[a-z[.]].xml

I know gitignore uses globbing but I can't seem to work out the correct combination I need: http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm

Thanks for any pointers in advance.


Solution

  • Posting answer supplied by @blami

    Setting "Cloud.Core*.xml" ignored the file as expected. This was the solution for me!