如何在我的本地和 github 存储库中保留一个文件的不同内容? [英] How to keep different content of one file in my local and github repository?
问题描述
我有一个database.php.我想把它保存在我的 github 存储库中,没有任何敏感信息.
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.
我添加到 .gitignore.我做了 rm --cached database.php.但是它在推送后从我的 github 存储库中删除了 database.php.
I added to .gitignore. And I did rm --cached database.php. But it deleted the database.php from my github repository after a push.
如何在本地和 github 存储库中保留不同的内容?
How can I keep different content in my local and github repository?
提前致谢.
推荐答案
您应该制作 2 个不同的文件,一个实际的 database.php
和一个 database.php.example
或类似的东西,然后将 database.php 添加到 .gitignore
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屋!