Conditional .gitignore based on origin

I have an application that I want to host on Heroku. It has sensitive database information that I don’t want pushed into the public repo on github… However, I can’t add it to the gitignore file, because then it won’t get pushed to heroku.

Is it possible to have a conditional gitignore, where I ignore that YML file in origin, but not heroku?

  • How do you manage database revisions on a medium sized project with branches?
  • How do I run gulp.js in my asp.net core project when deploying to Azure using git?
  • What does it mean to deploy a branch to localhost:port?
  • Ignoring certain files and changes in capistrano's current directory for development environment
  • How do your developers work using Git?
  • Migrating from Bamboo
  • Storing Drupal SQL in Git
  • Git: How to ignore/specify files for *checkout*
  • Branch/master tag revision increments using Git
  • Can I force git branch --contains <tag> to not print the asterisk?
  • GitHub Error Message - Permission denied (publickey)
  • Why doesn't git version directories?
  • 2 Solutions collect form web for “Conditional .gitignore based on origin”

    Unfortunately, no. Git doesn’t support that feature, so you are probably out of luck. There are various ways to get local-only ignore files in different repositories (.git/info/exclude), or on different machines (global ignore), but nothing on a per-origin basis.

    The easiest work-around might be to have a “public” branch that has that file deleted, and a pre-commit hook to ensure that the public branch never accepted a commit that added it.

    No assurances that won’t ever leak the blob to the public copy, however.

    You might want to look into Heroku db:push

    I’ve used that to synch data and you can still ignore all db info.

    Git Baby is a git and github fan, let's start git clone.