git time, ignore file in version control tool

Source: Internet
Author: User

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

1. Environment

Windows XP SP3 + tortoisegit + msysgit

2. Ignore Files three ways to

The following ignore files are in the format below:

#  line started, is treated as a comment .                                                                                                                                 

# Ignore All files with file names that are foo.txt .

Foo.txt

# Ignore all generated HTML files ,

*.html

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

!foo.html

# Ignore All . O and . A files .

*. [OA]

"Way One"

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

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, other developers update the file to the local repository to share the same set of ignore rules.

"Way Two"

Ignore the file by configuring the . Git/info/exclude file. This approach is globally valid for the warehouse and can only work on its own local repository, and others cannot share the ignore rule in this way unless others modify the file for their local repository as well.

"Way Three"

through the core of the . Git/config configuration file. Excludesfile option, specify an ignore rule file (full path) as shown in. Ignore the rule in the file e:/gitignore.txt (of course, the file name can be arbitrarily taken).

The scope of the method is also global.

Example

# Ignore *.O and *.A files

*. [OA]

# Ignore *.b and *. b file, except my.b

*. [BB]

!my.b

# Ignore DBG files and dbg directories

Dbg

# only the DBG directory is ignored and the DBG file is not ignored

dbg/

# only the DBG file is ignored and the DBG directory is not ignored

Dbg

!dbg/

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

/dbg

git time, ignore file in version control tool

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.