1,
Environment
Windows XP SP3 + tortoisegit + msysgit
2,
Three methods for ignore files
The following ignore files are in the following format:
# A row starting with '#' is considered as a comment. # Ignore all objects whose names are foo.txt. Foo.txt # Ignore all generated HTML files, *. Html # Foo.html is manually maintained, so the exception is. ! Foo.html # Ignore all. O and. A files. *. [OA] |
Method 1]
Create a file named. Gitignore'sFile (because it starts with a dot and there is no file name, you cannot directly create it in the Windows directory. You must right-click git
Bash, which is created in Linux. GitignoreFile ). As shown in.
The. gitignore file is valid for its directory and all subdirectories in the directory. By adding the. gitignore file to the repository, other developers update the file to the local repository to share the same set of ignore rules.
Method 2]
Ignore the file by configuring the. Git/INFO/exclude file. This method is globally effective for the repository and can only be used for the local repository. Others cannot share the ignore rules in this way unless others modify the file in the local repository.
Method 3]
Use the core. excludesfile option of the. Git/config configuration file to specify a file that ignores the rule (full path), as shown in. The ignore rules are in the file E:/gitignore.txt (of course, the file name can be arbitrary ).
The scope of this method is also global.
[Example]
# Ignore *. O and *. A files
*. [OA]
# Ignore *. B and *. B files, except my. B.
*. [BB]
! My. B
# Ignore dbg files and dbg Directories
Dbg
# Ignore only the dbg directory and not the dbg file
Dbg/
# Ignore only the dbg file and not the dbg directory
Dbg
! Dbg/
# Only the dbg files and directories under the current directory are ignored. The dbg of the subdirectory is not within the ignore range.
/Dbg