Git ignores and the. gitignore rule does not take effect. git. gitignore

Source: Internet
Author: User

Git ignores and the. gitignore rule does not take effect. git. gitignore

Git ignore rules:

If you want to ignore a file in git and prevent it from being submitted to the version library, you can modify it in the root directory. gitignore file method (if this file is not available, you need to manually create this file ). Each row of this file stores a matching rule, for example:

# This is a comment-it will be ignored by Git

*. Sample # ignore all files ending with. sample
! Lib. sample # Except lib. sample
/TODO # ignore the TODO file in the root directory of the project, excluding subdir/TODO
Build/# ignore all files in the build/directory
Doc/*. txt # will ignore doc/notes.txt, but does not include doc/server/arch.txt

. Gitignore rule does not take effect

Some directories or files are added to the ignore rule. After being defined according to the above method, it is found that the rule does not take effect because. gitignore can only ignore untracked files. If some files have been included in version management, modify them. gitignore is invalid. The solution is to first Delete the local cache (change to the untracked status), and then submit:

Git rm-r -- cached.
Git add.
Git commit-m'update. gitignore'

 

Related Article

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.