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.
gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them. Igal S.
gitignore file prevents future untracked files from being added to the git index. In other words, any files that are currently tracked will still be tracked by git.
gitignore . If you pull from a remote and that remote has changes to this path, git will fail the merge with a conflict and you will need to merge manually. git rm --cached <path> … will cause git to stop tracking that path.
The . gitignore will prevent files that Git does not track from being added to the set of files that the version control system is tracking. On the other hand, Git will not stop tracking a file that is already being tracked, even if you add it to .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With