1. Environment
Windows XP SP3 + tortoisegit + msysgit
2. Three methods of ignore files
The following ignore files are in the format below:
The row that the
# begins with ' # ' is treated as a comment. &n bsp; # ignores all file names that are foo.txt. Foo.txt # ignores all generated HTML files, *.html The # foo.html is manually maintained, so an exception. !foo.html # ignores all. O and. a files. *. [OA] |
"Mode One"
Create a new file named . Gitignore in the warehouse directory (because it is a point at the beginning, no file name, no way directly in the Windows directory directly created, you must right-click Git Bash, the Linux way to create new . Gitignore file). As shown in the following figure.
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, the other developer updates the file to the local repository to share the same set of ignored rules.
"Mode Two"
Ignore the file by configuring the. git/info/exclude file. This approach is global to the warehouse and can only work on its own local repository, and others cannot share the ignore rule in this way unless someone else modifies the file in their local warehouse.
"Mode three"
The core of the. Git/config configuration file is passed. Excludesfile option, specify an ignore rule file (full path), as shown in the following figure. Ignoring the rule is in the file E:/gitignore.txt (of course the file name can be arbitrarily taken).
The scope of this approach is also global.
Example
# Ignore *.O and *.A files
*. [OA]
# Ignoring *.B and *. b file, except my.b
*. [BB]
!my.b
# Ignore DBG files and dbg directories
Dbg
# Ignore DBG directory only, do not ignore DBG file
dbg/
# Ignore DBG files only, do not ignore DBG directory
Dbg
!dbg/
# only DBG files and directories under the current directory are ignored, and dbg of subdirectories are not in the ignored range
/dbg