For more information, see man gitignore.
Generally, some intermediate files are generated during the dev process of a project, which we do not want to trace.
You can use the. gitignore file in git to ignore these files.
Add the. gitignore file under the required directory.
Each line in the file indicates the regular expression of the file to be ignored.
$ Cat. gitignore
# Ignore. Metadata
. Metadata
. Gitignore
# Ignore OBJ and Lib File
*. [OA]
Current directory information
$ LS-Al
Total 24
Drwxr-XR-x 4 Root 4096.
Drwx ------ 51 Root 4096 ..
Drwxr-XR-x 8 Root 4096. Git
-RW-r -- 1 Root 39. gitignore
Drwxr-XR-x 3 Root 4096 2010-08-19 20:01. Metadata
-RW-r -- 1 Root 52 test.txt
If the file is not added, git status reports that these files do not have a track.
$ Git status
# On branch master
# Untracked files:
# (Use "Git add <File>..." to include in what will be committed)
#
#. Metadata/
# Gitignore
After the file is added, you can see that the workspace is clean.
$ MV gitignore. gitignore
[Root @~ /Workspace]
$ Git status
# On branch master
Nothing to commit (working directory clean)
This. gitignore is very simple. There is a. metadata in the current directory. This is not required, so the file is written. In addition, if the. gitignore line is not added, git will also add. gitignore to version control.