Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
1. Environment
Windows XP SP3 + tortoisegit + msysgit
2. Ignore Files three ways to
The following ignore files are in the format below:
#  line started, is treated as a comment . # Ignore All files with file names that are foo.txt . Foo.txt # Ignore all generated HTML files , *.html # foo.html is manually maintained, so the exception . !foo.html # Ignore All . O and . A files . *. [OA] |
"Way One"
Create a new file named . Gitignore in the warehouse directory (because it is the point at the beginning, no file name, no way directly in the Windows directory directly created, you must right-click Git Bash to create a new . gitignore file According to the Linux method). As shown in.
The . Gitignore file is valid for both the directory in which it resides and all subdirectories of the directory in which it resides. By adding the . Gitignore file to the warehouse, other developers update the file to the local repository to share the same set of ignore rules.
"Way Two"
Ignore the file by configuring the . Git/info/exclude file. This approach is globally valid for the warehouse and can only work on its own local repository, and others cannot share the ignore rule in this way unless others modify the file for their local repository as well.
"Way Three"
through the core of the . Git/config configuration file. Excludesfile option, specify an ignore rule file (full path) as shown in. Ignore the rule in the file e:/gitignore.txt (of course, the file name can be arbitrarily taken).
The scope of the method is also global.
Example
# Ignore *.O and *.A files
*. [OA]
# Ignore *.b and *. b file, except my.b
*. [BB]
!my.b
# Ignore DBG files and dbg directories
Dbg
# only the DBG directory is ignored and the DBG file is not ignored
dbg/
# only the DBG file is ignored and the DBG directory is not ignored
Dbg
!dbg/
# only the DBG files and directories in the current directory are ignored, and the dbg of subdirectories is not in the Ignore range
/dbg
git time, ignore file in version control tool