如何保持我的本地和github存储库中的一个文件的不同内容? [英] How to keep different content of one file in my local and github repository?

查看:115
本文介绍了如何保持我的本地和github存储库中的一个文件的不同内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个database.php。我想保留在我的github存储库中,没有任何敏感信息。

首先我没有任何敏感信息就推送到我的存储库。



现在我添加了数据库信息,以便本地使用它。



我添加到.gitignore。我做了rm --cached database.php。但它在推送后从我的github存储库中删除了database.php。

如何在本地和github存储库中保存不同的内容?



在此先感谢。

解决方案

您应该创建两个不同的文件,一个实际为 database.php 和一个 database.php.example 或类似的东西,然后添加database.php到 .gitignore


I have a database.php. I want to keep it in my github repository without any sensitive information.

First I pushed to my repository without any sensitive info.

Now I added my database info so that I can use it locally.

I added to .gitignore. And I did rm --cached database.php. But it deleted the database.php from my github repository after a push.

How can I keep different content in my local and github repository?

Thanks in advance.

解决方案

You should make 2 different files one actual database.php and one database.php.example or something like that and then add database.php to .gitignore

这篇关于如何保持我的本地和github存储库中的一个文件的不同内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆