Newy
Newy

Reputation: 40117

How can I exclude database.yml from a git repo while still being able to push to dotCloud?

I want to add a remote git collaborator on one of my projects, but I do not want to have him access my passwords in database.yml. I know how to .gitignore database.yml and purge the repo accordingly, but the trouble is I am deploying this particular project to DotCloud, which, as far as I know, requires the database.yml to be part of the git repo. The best solution I can think of now is using rsync to push to DotCloud, but I'd rather push directly from the git repo. Anyone know of a way I can do this?

Upvotes: 2

Views: 517

Answers (2)

Ken Cochrane
Ken Cochrane

Reputation: 77335

You have a couple of different options depending on what you want to do.

You can put the database.yml file in your .gitignore file, and then when using dotcloud push use rsync instead of git to push your code.

$ dotcloud push --all ramen

Using the --all option will force the uploader to use the “rsync” method, and therefore push all your files. See this page for more info. http://docs.dotcloud.com/guides/git-hg/#pushing-uncomitted-changes

If you need to ignore files then you can create a .dotcloudignore file, and add the files you want to ignore with the push there.

The second, better approach is to not put your passwords in your database.yml file at all. Add your passwords as environment variables, and then your database.yml file can be safe and free of passwords.

$ dotcloud var set myapp MYVAR=MYVALUE

You can then reference the variables the same way as you do with environment.yml or environment.json . More info can be found here: http://docs.dotcloud.com/guides/environment/#adding-environment-variables

Upvotes: 4

ddzialak
ddzialak

Reputation: 1080

NOTE 1: Suppose the simpler way is to create alias in git that would automatically execute rsync:

git config alias.<yourcommand>; !<your script>

Example:

git config alias.sendtocloud "! echo 'rsync' && rsync && echo pull && git pull"

and later try:

git sendtocloud <continue parameters as after git pull >

If you want to have pure git solution and at least 3 repos:

  • [Y]our: (database.yml not important?)
  • [C]ollaborator: (without database.yml)
  • [D]otCloud (with original databse.yml)

So there are additional questions:

  1. How do you share repository with your collaborator? (pull or push and by who?)
  2. OR do you have some bare repository to exchange data (shared by [Y] and [C])?
  3. Is that correct, that you don't need to have database.yml in your repo?

NOTE 2: you can use git hooks to do almost everything what you want. For example you can even manage with some temporary branches before update etc.

NOTE 3: If you don't need database.yml in your repo than you can create in-middle bare repo before [y] and [D] with "update" hook to forward changes to [D]

Upvotes: 0

Related Questions