我需要在我的 GitHub 存储库中包含一些文件,但不跟踪它们的更改。我怎样才能做到这一点?一个示例用例是包含敏感用户信息(例如登录凭据)的文件。
例如,我将此框架的新安装部署到新客户端,我想下载以下文件(它们具有默认值 CHANGEME),我只需要针对此客户端进行特定更改(数据库凭据、电子邮件地址信息、自定义 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
。然后我的所有更改都会被覆盖。
最佳答案
git 有不同的解决方案来做到这一点。首先更改您不想被跟踪的文件并使用以下命令:
git update-index --assume-unchanged FILE_NAME
如果您想再次跟踪更改,请使用此命令:
git update-index --no-assume-unchanged FILE_NAME
关于git - 将文件保存在 Git 存储库中,但不跟踪更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9794931/