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

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

问题描述

我在 CodeIgniter 站点中有几个文件,我希望将它们包含在存储库中,但不跟踪任何更改.

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

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

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

目前如果我运行

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

然后编辑上面的文件,一切都很好.直到我发布修补程序或补丁并运行 git pull.然后我的所有更改都将被覆盖.

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.

推荐答案

git 有一个不同的解决方案来做到这一点.首先更改您不想被跟踪的文件并使用以下命令:

git has a different solution to do this. First change the file you do not want to be tracked and use the following command:

git update-index --assume-unchanged FILE_NAME

如果您想再次跟踪更改,请使用以下命令:

and if you want to track the changes again use this command:

git update-index --no-assume-unchanged FILE_NAME

git-update-index 文档

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

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