.gitignore doesn't stop changes being tracked in files

11,316

With .gitignore, only untracked files are ignored.

Once the file has been added, change to that file are not ignored.

In this case, you should use assume-unchanged or skip-worktree instead.

git update-index --assume-unchanged -- wp-config.php

or

git update-index --skip-worktree -- wp-config.php
Share:
11,316

Related videos on Youtube

Alex
Author by

Alex

I'm a front-end & javascript developer in London.

Updated on September 16, 2022

Comments

  • Alex
    Alex over 1 year

    Changes I make to a file that's within my .gitignore are being tracked by git.

    File structure:

    .gitignore
    wp-config.php
    

    Contents of .gitignore:

    wp-config.php
    

    When I change wp-config.php, and then run git status I see that it has been modified:

    alex$ git status
    # On branch master
    # Changes not staged for commit:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #   modified:   wp-config.php
    #
    

    How to I stop tracking this file? I thought putting it in .gitignore would be enough.

  • Naveenbos
    Naveenbos over 7 years
    what about the other files, do i need to add all other files and folder like this? instead of adding git ignore?