Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
仅用于分支的Git Config excludesfile_Git_Github - Fatal编程技术网

仅用于分支的Git Config excludesfile

仅用于分支的Git Config excludesfile,git,github,Git,Github,我想在我的公共分支中排除一个名为config/dbconfig.js的文件,我使用该文件将其推送到github,但仍然能够从master推送到noester.com git repo以推送到生产。我将配置文件更改为: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true excludesfile = +info/exclude [remote "nodes

我想在我的公共分支中排除一个名为config/dbconfig.js的文件,我使用该文件将其推送到github,但仍然能够从master推送到noester.com git repo以推送到生产。我将配置文件更改为:

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
  excludesfile = +info/exclude
[remote "nodester"]
    url = *** My Git Repo ***
    fetch = +refs/heads/*:refs/remotes/nodester/*
[branch "public"]
  excludesfile = +info/exclude_public
我确保删除了.gitignore文件,我将.git/info/exclude文件用于常规排除,并希望使用.git/info/exclude\u public来排除该文件,因此当我合并到public时,该文件不会合并,也不会推送到github

如果我执行以下操作,它仍然会将文件添加到git中,即使在公共分支中也是如此。所以我想我的语法错了或者不可能

$ git checkout public
$ git add .
$ git status
# On branch public
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   new file:   config/dbconfig.json
#
$git签出公共
$git add。
$git状态
#关于公共部门
#要提交的更改:
#(使用“git重置磁头…”取消分级)
#
#新文件:config/dbconfig.json
#

如果这是不可能的,有没有更好的方法来处理数据库配置您不想在不运行两个git存储库并手动在它们之间合并的情况下退出一个开放的Github项目?

对于配置文件,最好处理内容过滤器驱动程序,而不是尝试忽略某些分支的文件

你会:

  • 存储配置文件模板
  • 存储公共价值
  • 让内容过滤器“
    smudge
    ”脚本使用模板和公共值构建目标配置文件,
    ... 除非该脚本检测到它在部署环境中,在这种情况下,它将使用来自该服务器上另一个源的值(而不是存储在repo中的公共值)
有关说明,请参见:

  • ”“或者
  • “”

好的,我想我在.git属性中得到了这样的东西?config/dbconfig.json合并=ours@JTWebMan:合并驱动程序也可以工作,但我使用筛选器驱动程序的目的是使用来自repo外部的值。那么在我的机器上是这样吗?我想我明白你的意思了,所以当我提交更改时,它将查看哪个分支,并替换我本地拥有的文件中不在repo中的值。它也适用于合并吗?@JTWebMan:它将在签出时替换(涂抹脚本),而不是提交。并创建一个私有文件(即不存储在repo中),因此与合并无关。其想法是将敏感数据保留在回购协议(及其历史)之外。