Ignore file ".gitignore" overview

    When using git to track and manage files, all files will be tracked by default, and the file ".gitignore" can be used to prohibit the tracking of files that meet the ignore rules.
    The format specification of the ignore file ".gitignore" is as follows:
    * All blank lines or lines starting with "#" will be ignored by Git.
    * can use standard glob pattern matching.
    * Matching patterns can start with (/) to prevent recursion.
    * The matching pattern can end with (/) to specify a directory.
    * To ignore files or directories outside the specified pattern, you can use an exclamation mark (!) before the pattern to negate it.
    Among them, the glob pattern refers to the simplified regular expression used by the shell. That is, an asterisk (*) matches zero or more arbitrary characters; [abc] matches any one of the characters listed in square brackets (this example either matches an a, a b, or a c); a question mark ( ?) matches only one arbitrary character; if you use a dash to separate two characters in square brackets, it means that everything in the range of these two characters can be matched (eg [0-9] means to match all numbers from 0 to 9 ). Use two asterisks (*) to match any intermediate directory, eg "a/**/z" can match a/z, a/b/z or "a/b/c/z" etc.
    The following is an example of a ".gitignore" file:
# no .a files
*.a

# but do track lib.a, even though you're ignoring .a files above
!lib.a

# only ignore the TODO file in the current directory, not subdir/TODO
/EVERYTHING

# ignore all files in the build/ directory
build/

# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt

# ignore all .pdf files in the doc/ directory
doc / ** / *. pdf

    GitHub has a very detailed list of ".gitignore" files for dozens of projects and languages, which you can find at https://github.com/github/gitignore .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326197658&siteId=291194637