Git Config excludes branch-only file

I wanted to exclude a file called config / dbconfig.js in my public branch, which I use to click on github, but I can still click from master to my noester.com git repo to move on to production. I changed the configuration 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 definitely deleted the .gitignore file, and I use the .git / info / exclude file for a general exception and was hoping to use .git / info / exclude_public to exclude this file, so when I merge with the publication, that file does not merge and not Click on github.

If I do the following, it will still add the file to git even in the public branch. Therefore, I think that my syntax is incorrect or impossible.

 $ 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 is not possible, is there a better way to handle database configurations that you don't want to exit an open Github project without running two git repositories and manually merging between them?

+3
source share
1 answer

For configuration files, it is best to use a content filter driver than try to ignore the file for specific branches.

content filters

You would:

  • save configuration file template
  • keep public values
  • enable smudge 'script content filter to create target configuration file from template and public values,
    ... except when the script discovers that it is in the deployment environment, in which case it will use values ​​from another source on this server (and not the public values ​​stored in the repo)

Look at the illustrations:

+2
source

All Articles