Git. gitignore file compilation, git. gitignore
. Gitignore exists in order to let git ignore the management of some files. Some files are generated according to the user's computer environment, which has no effect on the code, the update or synchronization may even fail. therefore, we need. gitignore File
There are three main ways to create it:
- Method 1]
Create a directory named. gitignore file (because it starts with a dot and has no file name, it cannot be directly created in the windows directory. You must right-click Git Bash to create a file in linux. gitignore file ). 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.
- [Other methods]
Currently, github, open-source China, and other libraries provide templates for developers to simplify our work. We only need to learn how to modify them.
Syntax notes
*. [Oa] # ignore *. B and *. B files, except my. B *. [bB]! My. B # ignore the dbg file and dbg directory dbg # ignore the dbg directory only, do not ignore the dbg file dbg/# Only ignore the dbg file, do not ignore the dbg directory dbg! Dbg/# Only the dbg files and directories under the current directory are ignored. The dbg of the subdirectory is not in the ignore range./dbg