问题描述
我是github上的新手,我正在开发一个具有config.php
文件的应用程序,您必须输入数据库凭据.
I am new at github and I am developing an app that has a config.php
file that you must enter the database credentials.
在我的github存储库中,文件是这样的:
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";
?>
在.gitignore
文件中,我将不想在开发时将其推送到github存储库的文件,但现在要做的是在拉动时忽略文件.
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.
我想要从github存储库更新我的网站,但我想忽略config.php
文件,因为该文件在每次安装中都必须是唯一的.
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.
我该怎么办?
推荐答案
.gitignore用于忽略未跟踪的文件,但是您需要忽略被跟踪文件中的更改.您可以使用git update-index --skip-worktree /path/to/config.php
.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
请参见 https://git-scm.com/docs/git- update-index#_skip_worktree_bit
这篇关于Git拖拉时忽略文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!