Reputation: 369
I am new at github and I am developing an app that has a config.php
file that you must enter the database credentials.
In my github repository the file is like this:
<?php
$host_name = "<HOST>";
$database = "<DATABASE>";
$user_name = "<USER>";
$password = "<PASSWORD>";
?>
But in the website i have the file with the credentials:
<?php
$host_name = "myhost";
$database = "mydatabase";
$user_name = "myuser";
$password = "mypassword";
?>
In the .gitignore
file I put the file that I don't want to push to my github repository when I am developing but what I want to do now is to ignore files when I make a pull.
What I want is to update my website from my github repository but I want to ignore the config.php
file because this must be unique in each install.
How can I do it?
Upvotes: 4
Views: 6491
Reputation: 364
To stop tracking a file you need to remove it from the index. This can be achieved with this command:
git rm --cached <file>
Commit that change
git commit -am "Remove ignored config.php"
Upvotes: 1
Reputation: 7538
.gitignore is for ignoring untracked files, but you need to ignore changes in the tracked one. you could use git update-index --skip-worktree /path/to/config.php
See https://git-scm.com/docs/git-update-index#_skip_worktree_bit
Upvotes: 3