Git Config仅为分支排除文件 [英] Git Config excludesfile for just a branch
问题描述
我想在公共分支中排除一个名为config / dbconfig.js的文件,我使用这个文件将它推送到github,但仍然能够从主服务器推送到我的noester.com git repo以推送到产品。我将配置文件更改为:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
excludesfile = + info / exclude
[remotenodester]
url = ***我的Git Repo ***
fetch = + refs / heads / *:refs / remotes / nodester / *
[branchpublic]
excludesfile = + info / exclude_public
我一定要删除.gitignore文件,并且我正在使用.git / info / exclude文件作为一般排除项,并希望使用该文件。 git / info / exclude_public排除一个文件,所以当我合并到公共文件不合并以及不推送到github。
如果我做了以下它仍然会将该文件添加到git中,即使在公共分支中也是如此。所以我在想以太,我有语法错误或者它是不可能的。
$ git checkout public
$ git add 。
$ git status
#在分支上public
#要提交的更改:
#(使用git reset HEAD< file> ...以取消存储)
#
#新文件:config / dbconfig.json
#
如果这是不可能的是有没有更好的方式来处理数据库配置,你不想在一个开放的Github项目上出去,而无需运行两个git仓库并手动合并它们?
对于配置文件,最好处理内容过滤器驱动程序,而不是试图忽略某些分支的文件。 b
您可以:
smudge
'脚本将目标配置文件从模板和公共值中删除,
...除非该脚本检测到该情况是在部署环境中,在这种情况下,它会使用该服务器上其他来源的值(而不是存储在回购站中的公共值)
< b
$ b
I wanted to exclude a file called config/dbconfig.js in my public branch which I use to push to github but still be able to push from master to my noester.com git repo to push to production. I changed the config file to this:
[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
I made sure to remove the .gitignore file and I am using the .git/info/exclude file for the the general excludes and was hoping to use the .git/info/exclude_public to exclude that one file so when I merge to public that file doesn't merge as well as not push to github.
If I do the following it will still add the file to git even in the public branch. So I am thinking ether I have the syntax wrong or it's not possible.
$ 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
#
If this isn't possible is there a better way to deal with database configs you do not want to get out on a open Github project without running two git repositories and manually merge between them?
For config files, it is best to deals with content filter drivers than trying to ignore a file for certain branches.
You would:
- store a config file template
- store public values
- let a content filter '
smudge
' script build the target config file out of the template and public values,
... except when that script detects it is on the deployment environment, in which case it would use values from another source on that server (and not public values stored in the repo)
See for illustration:
- "Different databases for specific branches of git project" or
- "When a commit to revision control requires a developer to change their own config"
这篇关于Git Config仅为分支排除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!