具有一些不同文件的GIT存储库 [英] GIT repositories with some different files

查看:34
本文介绍了具有一些不同文件的GIT存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用Git.
我有:

I'm just getting started with Git.
I've got:

  • 本地计算机上用于Web开发的存储库/www/my-web-app/
  • 在远程服务器上,我有一个裸存储库/www/git-repo/,然后是实际的Web应用程序/www/production-my-web-app/
  • a repository on my local machine for web development /www/my-web-app/ and
  • on a remote server I have a bare repository /www/git-repo/ and then the actual web app /www/production-my-web-app/.

我当前正在从本地计算机推送到裸存储库,然后将其拉入生产存储库.

I'm currently pushing from my local machine to the bare repository and then pulling that in the production repository.

问题是我有几个配置文件在生产中有所不同.
我忽略了它们,但是我想不出一种上传它们的方法(由于某种原因无法通过FTP进行上传),而且我确定我只是缺少明显的git工具.

The issue is I have a couple of config files that are different in production.
I have them ignored but I can't figure out a way to upload them (can't do it via FTP for some reason) and I'm sure I'm just missing an obvious facility of git.

感谢您的帮助,谢谢!

推荐答案

您可能会错过的功能,应该对您有用的功能是"

The feature you might have missed and should help in your case is the "content filter driver", especially the smudge step.

这个想法是要版本a:

  • 您的配置文件模板
  • 能够获取模板并生成私有(即非版本化)配置文件的脚本(污迹)
  • 一些非生产值(从本地计算机调用时由脚本使用)

这样,相同的污迹脚本在生产环境中使用时将使用外部值,即秘密值未存储在git repo中(对其进行克隆/推送没有危险).
与您可以在Git存储库中安全地对这些测试值进行版本控制的本地计算机相反.

That way, that same smudge script will use external values when used in a production environment, that is secret values not stored in a git repo (no danger for them to be cloned/pushed around).
As opposed to your local machine where those test values can be safely versioned in a Git repo.

如果没有秘密数据"问题,您可以简单地对多个配置值"文件进行版本控制,每个环境一个,然后将其留给您的涂抹脚本:

If there is no "secret data" issue, you can simply version several "config value" files, one per environment, leaving it to your smudge script to:

  • 检测它在什么环境中被调用(在 git checkout 期间自动)
  • 使用正确的配置值"脚本生成正确的配置文件.

这篇关于具有一些不同文件的GIT存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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