The .gitignore File
Specify files and directories that Libra should ignore
Introduction
The .gitignore file, or more precisely in this project, the .libraignore file, is used to specify files and directories that Libra should ignore. These files and directories will not be tracked by Libra. If a file is already tracked by Libra, the .libraignore file will not affect it.
The patterns in the .libraignore file determine whether a path should be ignored. These patterns can be simple filenames, wildcards, or more complex patterns.
.libraignore File Usage
Compatibility with Gitignore Patterns
The .libraignore file supports the same pattern syntax as .gitignore. This includes:
- Simple Filenames: Directly specify a filename. For example,
file.txtmatches a file namedfile.txtin the current directory. - Wildcards: Use
*to match any sequence of characters. For example,*.tmpmatches all files ending with.tmp. - Directory Matching: Use
/to match directories. For example,dir/matches a directory nameddir. - Recursive Matching: Use
**to match any path. For example,**/*.tmpmatches all files ending with.tmpin any directory. - Exclusion Patterns: Use
!at the beginning of a pattern to exclude files that were previously matched. For example,!file.txtexcludesfile.txtfrom being ignored. - Comments: Lines starting with
#are treated as comments and are not parsed.
Matching Rules
Libra checks for .libraignore files from the directory of the target file upwards to the root of the working directory. If a match is found in any .libraignore file, the file will be ignored.
- Matching Order: Libra starts checking from the directory of the target file and moves upwards. Once a match is found, Libra stops checking and ignores the file.
- Subdirectory Precedence: If multiple
.libraignorefiles contain matching patterns, the patterns in the.libraignorefile closest to the target file take precedence.
Support for .libraignore in Subdirectories
Libra supports placing .libraignore files in any subdirectory within the working directory. Libra will check for .libraignore files from the directory of the target file upwards to the root of the working directory. If a match is found in any .libraignore file along the path, the file will be ignored.
- Subdirectory
.libraignoreFiles: The patterns in a.libraignorefile within a subdirectory are relative to that subdirectory. For example, if there is a pattern*.tmpinwork_dir/subdir/.libraignore, it will matchfile.tmpwithinsubdir, but notfile.tmpin the root of the working directory.