Is there a simple way to setup different .gitignore files for different remotes? I have a repository I push up to both Heroku and Github. I need database.yml for Heroku, but don't want some of the information to be pushed up to Github. So I need a different .gitignore file for each of the remotes.
I tried having two separate branches, one that ignores database.yml, and one that doesn't. The problem is that when I checkout the heroku branch and go back into my github branch, the entire database.yml file is gone.
Any tips?
You should versionned a:
database.yml
with only variables in it, anddatabase.yml
is deployed.Then you use the script as a smudge attribute filter driver:
Each time you will checkout (and create a working tree) on a remote server, the script is executed and will change the variables accordingly, giving you a custom
database.yml
file.If one of the remote does not need that
database.yml
file, it can still be there, but emptied by the smudge script.I don't know anything about the requirements for Heroku - hopefully Justice is right and you can simply avoid the problem. If you can't, or if someone else finds this who can't...
If you want the two remotes to be mirrors (have the same commits), they must by definition have the same files in those commits. So, you have two choices: have
file-for-repo-B
in all repositories, even if they don't need it, or use a slightly messy workflow with two branches:master
andfor-repo-B
. The only difference between the two branches would be the commits touchingfile-for-repo-B
; the branchfor-repo-B
would always merge frommaster
(but never the other way around!). Now you just have a different branch checked out in repo B, and all is good.Do not put database information in database.yml. Instead, use Heroku environment variables.