Using github to host public git repositories whilst ensuring that sensitive data files remain untracked

后端 未结 4 843
你的背包
你的背包 2020-12-08 08:25

My app is hosted on Heroku and I have a public github repo too.

My app has a config file containing my amazon S3 credentials. It\'s important to ensure that the fil

相关标签:
4条回答
  • 2020-12-08 08:58

    If you use a branch named heroku as your "alternative master" branch (with sensitive data) and your old master branch without the sensitive data, then you could always do

    git merge master
    

    So you can push heroku branch to heroku not the master branch.

    0 讨论(0)
  • 2020-12-08 09:03

    in SVN this is called 'ignoring files' so I assume it will be something similar in GIT - I don't use GIT so don't quote me on this, but I've found this reference on the GITHub website:

    http://github.com/guides/ignore-for-git

    Hope that helps

    0 讨论(0)
  • 2020-12-08 09:07

    You could maybe move the "dangerous" files away from git entirely - eg have them in ~/.yourapp or something like that. (that doesn't really answer the question directly but its what lots of software does - .fetchmail, .ssh, ...) and would permit other users to do the same.

    0 讨论(0)
  • 2020-12-08 09:12

    But this causes the s3.yml and gitignore files from the master branch to get copied into the github branch

    You can avoid that with a custom merge driver which will make sure to the .gitignore file of the github branch will always retain its content over the one merged from master.

    See How do I tell git to always select my local version for conflicted merges on a specific file?

    0 讨论(0)
提交回复
热议问题