Git ignores files and git ignores

Source: Internet
Author: User

Git ignores files and git ignores
Git ignores files:

Git provides a file ignore system. When a directory or file in the workspace is ignored, the ignored files are not displayed even if they exist during status check.
In this way, I can ignore the files or directories that do not need to be uploaded or retained (such as dynamically generated logs or compiled files ).

Git provides three methods for ignoring files (the great gods in our group also told me another method:

I.. gitignore sets Remote sharing to ignore files. Use gitignore:

First, we can see from the file name that. gitignore is a hidden file. Generally, it is created in the root directory of the repository by default (or any directory in the repository)
As follows:
cdTo the root directory;
ls -aView All hidden files;
vim .gitignoreCreate or edit the. gitignore file and write the file to be ignored;

Ignore file rules:

*. A ignores all files suffixed with.;
! Lib. a does not ignore the file lib.;
/TODO only ignores the TODO file in this directory, and the TODO file in the subdirectory is not ignored;
Build/ignore all files in the build directory;
Doc/*. txt only ignores all txt files under doc/, but does not ignore txt files under doc/subdir;

TIPS:
  1. Files. gitignore can be stored in any directory in the current repository;
  2. Ignore is only valid for files not tracked and invalid for files already added to the version library;
  3. If you do not want to add. gitignore to the library or the. gitignore file to cause any interference, you can ignore yourself in the ignore file;
Ii. Local exclusive

The. gitignore is usually uploaded to the remote version library, so it is "shared". In some cases, we need to have a local ignore file that is "exclusive.

Specific version Library:

In this version Library.git/info/excludeOr you can use the. gitignore file to ignore the file to achieve the same effect.

Global version Library:

Global ignore refers to ignoring all local version libraries.
Set git config:
$ git config --global core.excludefile /dean/.gitignore_global
/Dean/. gitignore_global is a custom ignore file. The directory, name, and content of this file are set as needed.

A great god tells you how:

Enter. config/git on the local machine, which contains an ignore file.
You can add the content you want to ignore in this file to ignore the global content.
The following command is convenient:vim .config/git/ignore

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.