Git ignore file (ignore file)

Source: Internet
Author: User

1,
Environment

Windows XP SP3 + tortoisegit + msysgit

 

2,
Three methods for ignore files

 

The following ignore files are in the following format:

# A row starting with '#' is considered as a comment.

# Ignore all objects whose names are foo.txt.

Foo.txt

# Ignore all generated HTML files,

*. Html

# Foo.html is manually maintained, so the exception is.

! Foo.html

# Ignore all. O and. A files.

*. [OA]

 

Method 1]

Create a file named. Gitignore'sFile (because it starts with a dot and there is no file name, you cannot directly create it in the Windows directory. You must right-click git
Bash, which is created in Linux. GitignoreFile ). 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.

[Example]

# Ignore *. O and *. A files

*. [OA]

# Ignore *. B and *. B files, except my. B.

*. [BB]

! My. B

# Ignore dbg files and dbg Directories

Dbg

# Ignore only the dbg directory and not the dbg file

Dbg/

# Ignore only the dbg file and not the dbg directory

Dbg

! Dbg/

# Only the dbg files and directories under the current directory are ignored. The dbg of the subdirectory is not within the ignore 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.