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

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

问题描述

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

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.

我尝试有两个独立的分支,一个忽略 database.yml,一个不忽略.问题是,当我检出 heroku 分支并返回到我的 github 分支时,整个 database.yml 文件都不见了.

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.

有什么建议吗?

推荐答案

我对 Heroku 的要求一无所知 - 希望 Justice 是正确的,你可以简单地避免这个问题.如果你不能,或者如果其他人发现这个谁不能......

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...

如果您希望两个遥控器成为镜像(具有相同的提交),根据定义,它们在这些提交中必须具有相同的文件.因此,您有两种选择:在所有存储库中使用 file-for-repo-B,即使它们不需要它,或者使用带有两个分支的稍微凌乱的工作流程:masterfor-repo-B.两个分支之间的唯一区别是提交涉及file-for-repo-B;分支 for-repo-B 总是从 master 合并(但绝不会反过来!).现在你只是在 repo B 中签出了一个不同的分支,一切都很好.

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天全站免登陆