Use. gitignore to ignore certain files

Source: Internet
Author: User

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.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.