Git's ignored file (ignore files)

Source: Internet
Author: User

1. Environment

Windows XP SP3 + tortoisegit + msysgit

2. Three methods of ignore files

The following ignore files are in the format below:

The row that the

# begins with ' # ' is treated as a comment.            &n bsp;                                                                                                                    

# ignores all file names that are foo.txt.

Foo.txt

# ignores all generated HTML files,

*.html

The

# foo.html is manually maintained, so an exception.

!foo.html

# ignores all. O and. a files.

*. [OA]

"Mode One"

Create a new file named . Gitignore in the warehouse directory (because it is a point at the beginning, no file name, no way directly in the Windows directory directly created, you must right-click Git Bash, the Linux way to create new . Gitignore file). As shown in the following figure.

The. gitignore file is valid for both the directory in which it resides and all subdirectories of the directory in which it resides. By adding the. gitignore file to the warehouse, the other developer updates the file to the local repository to share the same set of ignored rules.

"Mode Two"

Ignore the file by configuring the. git/info/exclude file. This approach is global to the warehouse and can only work on its own local repository, and others cannot share the ignore rule in this way unless someone else modifies the file in their local warehouse.

"Mode three"

The core of the. Git/config configuration file is passed. Excludesfile option, specify an ignore rule file (full path), as shown in the following figure. Ignoring the rule is in the file E:/gitignore.txt (of course the file name can be arbitrarily taken).

The scope of this approach is also global.

Example

# Ignore *.O and *.A files

*. [OA]

# Ignoring *.B and *. b file, except my.b

*. [BB]

!my.b

# Ignore DBG files and dbg directories

Dbg

# Ignore DBG directory only, do not ignore DBG file

dbg/

# Ignore DBG files only, do not ignore DBG directory

Dbg

!dbg/

# only DBG files and directories under the current directory are ignored, and dbg of subdirectories are not in the ignored range

/dbg

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.