开发者

Git Config excludesfile for just a branch

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 t开发者_JS百科o 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.

Git Config excludesfile for just a branch

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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜