What is a good git practice to denote that a changed file should never be committed?
For example, for a WordPress theme development project, I am tracking the original WordPress files in git; and the wp-config.php config file, which contains local info that only pertains to the current system, needs to be changed but I don't want to commit it to git.
In Perforce, I used to save this type of event as a numbered changelist and never check it in. I was wondering whether a similar trick is available with git.
gitignore list does not work to ignore files that are already committed into the Git repository. This means that if you: Make a commit to your Git repository, and then; Set up your .
Creating an ignore file To avoid having to ignore unwanted files manually, you can create a . gitignore file in the working directory of your project. Inside this file, you can specify simple patterns that Git will use to determine whether or not a file should be ignored.
For files that aren't tracked by Git, you can use a . gitignore or exclude file. For files that are tracked by Git, you can tell Git to stop tracking them and to ignore changes.
If you still want to keep wp-config.php
versioned, but ignore any local change to it:
git update-index --assume-unchanged wp-config.php
This is different that a .gitignore, which would only work if you remove first wp-config.php
from the index:
git rm --cache `wp-config.php`
echo wp-config.php >> .gitignore
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