有没有办法设置远程特定的.gitignores? [英] Is there a way to setup remote-specific .gitignores?

查看:110
本文介绍了有没有办法设置远程特定的.gitignores?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法来为不同的遥控器设置不同的.gitignore文件?我有一个仓库,我推到了Heroku和Github。我需要Heroku的database.yml,但不希望某些信息被推送到Github。所以我需要为每个遥控器使用不同的.gitignore文件。

我尝试了两个单独的分支,一个忽略database.yml,另一个不支持。问题是,当我检出heroku分支并返回到我的github分支时,整个database.yml文件都消失了。



任何提示?

解决方案

对Heroku的要求 - 希望正义是正确的,你可以简单地避免这个问题。如果你不能,或者别人发现这个人不能... ...

如果你想让两个遥控器成为镜像(具有相同的提交),它们必须按照定义在这些提交中具有相同的文件。因此,您有两种选择:在所有存储库中都有 file-for-repo-B ,即使他们不需要它,或者使用稍微凌乱的工作流和两个分支: master for-repo-B 。两个分支之间的唯一区别是触及 file-for-repo-B 的提交;分支 for-repo-B 会始终从 master 合并(但绝不会反其道而行!)。现在你只需要在回购B中签出一个不同的分支,而且一切都很好。


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?

解决方案

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 and for-repo-B. The only difference between the two branches would be the commits touching file-for-repo-B; the branch for-repo-B would always merge from master (but never the other way around!). Now you just have a different branch checked out in repo B, and all is good.

这篇关于有没有办法设置远程特定的.gitignores?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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