对 git 工作流程感到困惑 (PHP/MySQL)
我对 PHP/MySQL 工作流程中 git 的正确工作流程有疑问。 git 存储库有一个包含“空白”数据库数据的配置文件,就像任何 PHP/MySQL 应用程序一样。我的问题与开发(拉/克隆)有关 ->发展阶段->生产(推)。
因此,我希望能够克隆我的存储库(空白 MySQL 配置文件),在我的开发实例上进行一些开发(这是我编辑“空白”配置文件的地方),其中包括测试,然后推回到存储库(带有空白 MySQL 文件,而不是密码信息)。
这可能非常简单,我只是不知道 git 如何做这样的事情。
I have a question regarding the proper workflow of git in a PHP/MySQL workflow. The git repository has a config file with "blank" database data, just like any PHP/MySQL application. MY question is related to development (pulling/cloning) -> development stage -> production (push).
So, I want to be able to clone my repository (blank MySQL config file), do some development (this is where I'd edit the "blank" config file) on my dev instance which includes testing, and then push back to the repository (with a blank MySQL file, instead of with password information).
This might be super easy, I just do not have the knowledge of how git could do such a thing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建另一个与当前配置文件同名的文件,并在其末尾添加 .sample 或 .dist 之类的内容。即在我的系统上,我个人在 config.php 中有我的设置,它会被 git 忽略,并且永远不会上传到该网站,而且我还有一个 config.php.dist (如发行版),它将推送到存储库。
因此,当您的客户下载它时,他们只需重命名 config.php.dist 并删除 .dist 部分。
第二件事是,您需要在 repo 文件夹的根目录中创建一个 .gitignore,并添加您不想上传到 repo 的文件名。
.gitignore 的内容
配置.php.dist
Create another file with the same name as your current config file and add something like .sample or .dist to the end of it. i.e on my system i personally have my settings in config.php which is ignored by git and will never upload to the site, and i also have a config.php.dist (like distribution) which will push up to the repo.
So when your client downloads it, they just need to rename config.php.dist and remove the .dist part.
Second thing to do, you need to create a .gitignore in the root of the repo folder, and add the file name that you do not want to upload to the repo.
Contents of .gitignore
config.php.dist