将文件保存在Git仓库中,但不要跟踪更改 [英] Keep file in a Git repo, but don't track changes

查看:101
本文介绍了将文件保存在Git仓库中,但不要跟踪更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CodeIgniter站点中有几个文件,我希望在回购站中有这些文件,但不会跟踪任何更改。

例如,我部署了一个新的安装我希望下载下列文件(它们具有默认值CHANGEME),我只需要针对此客户端(数据库凭据,电子邮件地址信息,自定义CSS)进行更改。

  //生产配置文件我想要这些文件,但它们需要更新为特定的客户端需求
application / config / production / config.php
application / config / production / database.php
application / config / production / tank_auth.php
//索引页面,定义环境(生产|开发)
/index.php
//所有css / js缓存(保留文件夹,但不保存内容)
/ assets / cache / *
//基于生产用户的样式(颜色,字体等)需要根据客户需求进行更新
/assets/frontend/css/user/frontend-user.css

目前如果我运行

  git clone git@github.com:user123 / myRepo.git httpdocs 

然后编辑上面的文件,一切都很好。直到我发布修补程序或修补程序并运行 git pull 。我的所有更改都将被覆盖。 为我的Code Igniter项目,我保持 database.php.example 配置 .php.example 。repo。

然后我添加 config.php applications / config / database。 php 添加到 .gitignore 文件中。

最后,当我部署时,我可以将.example文件config.php和database.php),自定义它们,并且它们不会被GIT跟踪。


I have several files in a CodeIgniter site that I will want to have in the repo but not track any changes on.

For example, I deploy a new installation of this framework to a new client, I want the following files to be downloaded (they have default values CHANGEME) and I just have to make changes specific to this client (database credentials, email address info, custom CSS).

// the production config files i want the files but they need to be updated to specific client needs
application/config/production/config.php
application/config/production/database.php
application/config/production/tank_auth.php
// index page, defines the environment (production|development)
/index.php
// all of the css/js cache (keep the folder but not the contents)
/assets/cache/*
// production user based styling (color, fonts etc) needs to be updated specific to client needs
/assets/frontend/css/user/frontend-user.css

Currently if I run

git clone git@github.com:user123/myRepo.git httpdocs

and then edit the files above, all is great. Until I release a hotfix or patch and run git pull. All of my changes are then overwritten.

解决方案

For my Code Igniter projects, I keep database.php.example and config.php.example in the repo.

Then I add config.php and applications/config/database.php to the .gitignore file.

So, finally, when I deploy, I can copy the .example files (to config.php and database.php), customize them, and they won't get tracked by GIT.

这篇关于将文件保存在Git仓库中,但不要跟踪更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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