Home > Article > Backend Development > What is the gitignore file for?
The ".gitignore" file allows you to ignore the original rules, or you can make your own rules according to your own needs. When using git, there will always be some files that do not need to be included in git management, and you do not want them to appear in the untracked file list. In this case, you can use the ".gitignore" file to automatically ignore these files.
The operating environment of this tutorial: windows7 system, python3 version, Dell G3 computer.
Summary: Sometimes, we must put certain files into the Git working directory, but cannot submit them, such as the development environment automatically generates intermediate files and saves the configuration of the database password. document. However, git status will display multiple untracked files every time, which affects our use of Git.
Fortunately, Git has taken everyone's feelings into consideration, and the solution to this problem is very simple. Create a special .gitignore
file in the root directory of the Git workspace , and then fill in the file names to be ignored, and Git will automatically ignore these files.
There is always a .gitignore hidden file in the root directory, and the function of this hidden file is not only to ignore the original rules, but also to make your own rules according to your own needs;
There is no need to write the .gitignore
file from scratch. GitHub has prepared various configuration files for us. You only need to combine them to use them. All configuration files can be browsed directly online: https://github.com/github/gitignore
The principle of ignoring files is:
1. Ignore intermediate files, executable files, etc. generated by compilation , that is, if a file is automatically generated through another file, then there is no need to put the automatically generated file into the repository, such as the .class
file generated by Java compilation;
2 , business data generated when the project is running, such as user thumbnails, user information, etc.;
3. Ignore your own configuration files with sensitive information, such as configuration files that store passwords
If we want to ignore .pyc, .pyo, dist and other files or directories generated by Python compilation, we can write the .gitignore file like this:
# Python: *.py[cod] *.so *.egg *.egg-info dist build
Related free learning recommendations : python video tutorial!
The above is the detailed content of What is the gitignore file for?. For more information, please follow other related articles on the PHP Chinese website!