我在CodeIgniter站点中有几个文件,我希望在repo中有这些文件但不跟踪任何更改.
例如,我将此框架的新安装部署到新客户端,我希望下载以下文件(它们具有默认值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
Run Code Online (Sandbox Code Playgroud)
目前如果我跑
git clone git@github.com:user123/myRepo.git httpdocs
Run Code Online (Sandbox Code Playgroud)
然后编辑上面的文件,一切都很棒.直到我发布修补程序或补丁并运行git pull.然后我的所有更改都会被覆盖.
nas*_*han 573
git有一个不同的解决方案来做到这一点.首先更改您不想跟踪的文件,然后使用以下命令:
git update-index --assume-unchanged FILE_NAME
Run Code Online (Sandbox Code Playgroud)
如果要再次跟踪更改,请使用以下命令:
git update-index --no-assume-unchanged FILE_NAME
Run Code Online (Sandbox Code Playgroud)
Ant*_*ony 59
从另一个答案的评论中得出答案:
$ git update-index --skip-worktree FILENAME
看起来比一个更好的选择 --assume-unchanged
关于此更多内容可以在这里阅读:Git - '假设未更改'和'跳过工作树'之间的区别
sup*_*ggy 57
对于我的Code Igniter项目,我在repo中保留了database.php.example和config.php.example.
然后我将config.php和applications/config/database.php添加到.gitignore文件中.
所以,最后,当我部署时,我可以复制.example文件(到config.php和database.php),自定义它们,它们不会被GIT跟踪.
从 git 版本 2.25.1 开始,推荐的方法是跟踪存储库中文件的模板,将它们复制到新文件中并在本地修改它们(忽略 中的新文件名.gitignore)(来自此处):
用户经常尝试使用假设未更改和跳过工作树位来告诉 Git 忽略对被跟踪文件的更改。这不会按预期工作,因为在执行某些操作时,Git 可能仍会根据索引检查工作树文件。通常,Git 不提供忽略跟踪文件更改的方法,因此建议使用替代解决方案。
例如,如果您要更改的文件是某种配置文件,则存储库可以包含一个示例配置文件,然后可以将其复制到忽略的名称中并进行修改。存储库甚至可以包含一个脚本来将示例文件视为模板,自动修改和复制它。
| 归档时间: |
|
| 查看次数: |
67719 次 |
| 最近记录: |