使用github托管公共git存储库,同时确保敏感数据文件保持未被跟踪 [英] Using github to host public git repositories whilst ensuring that sensitive data files remain untracked

查看:115
本文介绍了使用github托管公共git存储库,同时确保敏感数据文件保持未被跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在Heroku上托管,我也有一个公共github回购。



我的应用程序有一个包含我的亚马逊S3凭证的配置文件。确保文件被推送到heroku而不是github是非常重要的。

所以我想我可以推动我的master分支到heroku并创建一个独立的github分支,确保它的.gitignore文件引用我的s3.yml文件。然后,我可以做git push origin github:master将github分支推送到github.com。
$ b

这对于第一次提交工作正常。



然后我切换到我的主分支,编写一些很棒的代码,然后全部推送到heroku。然后我切换回我的github分支,并执行git merge master,以便将新代码添加到它。但是这会导致master分支的s3.yml和gitignore文件被复制到github分支中。提示头对头敲打会话。



有没有关于如何保持分支同步的建议,同时确保未跟踪的文件保持未被跟踪。我可以告诉git不要合并到不需要的S3.yml文件和不同的.gitignore文件中吗?



我在这里鞭打死马吗?我不能证明支付私人github帐户,但我想答案将涉及做到这一点....或切换到projectlocker

我希望这个问题只是我的垃圾git技能,并有一种方法....预先感谢

::接受的答案是一个很好的解决方案,但我刚刚找到了一个我更喜欢的新的。请阅读此处: http://docs.heroku.com/config-vars - 那些聪明的人在Heroku的人有一个答案的一切...严重真棒

解决方案


但这导致s3 .yml和gitignore文件从master分支复制到github分支中

您可以避免使用自定义合并驱动程序将确保github分支的.gitignore文件始终将其内容保留在与master合并的内容上。



请参阅如何让git始终选择我的本地版本来处理特定文件上的冲突合并?


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 file gets pushed to heroku but not github.

So I was thinking that I could push my master branch to heroku and create a seperate github branch and ensure that it's .gitignore file references my s3.yml file. I could then just do "git push origin github:master" to push the github branch to github.com

This works fine for the first commit.

But then I switch to my master branch, write some awesome code and then push it all to heroku. I then switch back to my github branch and do "git merge master" so that the new code gets added to it. But this causes the s3.yml and gitignore files from the master branch to get copied into the github branch. Cue head-to-desk banging session.

Is there any advice on ways to keep branches synched up whilst ensuring that untracked files remain untracked. Can I tell git not to merge in the unwanted S3.yml file and the different .gitignore file?

Am I flogging a dead horse here? I can't justify paying for a private github account yet but I imagine the answer will involve doing just that.... or switching to projectlocker

I'm hoping that this problem is just down to my crap git skills and that there is a way.... thanks in advance

EDIT::: The accepted answer is a great solution, but I've just found a new one that I like much more. Read about it here: http://docs.heroku.com/config-vars - those clever people at Heroku have an answer for everything... seriously awesome

解决方案

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?

这篇关于使用github托管公共git存储库,同时确保敏感数据文件保持未被跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆