git update-index--assume-unchanged (ignoring changes to tracked files)

Source: Internet
Author: User
Tags tmp folder

In Git, if you want to ignore a file and not commit the file to the repository, you can use the method that modifies the. gitignore file. Each row of this file holds a matching rule for example:

# This is a comment – will be ignored by Git

             *.a       # Ignore All. A End of File
           !lib.a    # except LIB.A
           /todo     # Just ignore the TODO file under the project root, not including Subdir/todo
            build/     # ignores all files under the build/directory

Doc/*.txt # ignores Doc/notes.txt but does not include Doc/server/arch.txt

This sets up all future. pyc files that are not added to the repository.

In addition, GIT provides a global. Gitignore , you can create a ~/.gitignoreglobal file under your user directory, using the same rules to delimit which files are not required for version control.

You need to execute git config--global core.excludesfile ~/.gitignoreglobal to make it effective.

Some of the other filtering conditions

* ? : Represents any one character
* *: Represents any number of characters
* {!AB}: Must not be of this type
* {AB,BB,CX}: Represents any type of AB,BB,CX
* [ABC]: represents any one character in A,b,c

* [^ABC]: represents must not be any one character in A,b,c

 tmp/*            //Ignore TMP folder all files

     to change the method, under TMP also add a. Gitignore, the content is
                         *
                        !. Gitignore
    Another case is that it is already committed, and then adding Gitignore is not valid, so you need to delete the next cache
                         git rm-r--cached ignore_file


Note:. Gitignore can only ignore files that were not previously track, and if some files have already been included in version management, modify the. Gitignore is not valid.

     the correct approach is to manually set up in each clone down warehouse to not check for specific file changes.
    git update-index--assume-unchanged path    Enter the file you want to ignore at PATH.

    In addition git also provides another way to exclude to do the same thing, unlike the. Gitignore the file itself is submitted to the repository. It is used to save the public files that need to be excluded. The. Git/info/exclude here is the file you need to exclude locally. He will not affect other people. Will not be submitted to the repository.

   . Gitignore also has an interesting little feature, an empty. gitignore file can be considered as a placeholder. This becomes useful when you need to create an empty log directory for your project. You can create a log directory to place an empty. gitignore file inside. So when you clone this repo git will automatically create an empty log directory.


---------------------------------------------------------------------------------------------------------------

Local permanent neglect, the effect of gitignore, just not suitable for writing to Gitignore, you can build a local gitignore, and then git config--global core.excludesfile file absolute path, You can also add files that are local to ignore directly to the. Git/info/exclude.

$ git update-index--assume-unchanged/path/to/file #忽略跟踪

$ git update-index--no-assume-unchanged/path/to/file #恢复跟踪


git update-index--assume-unchanged (ignoring changes to tracked files)

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.