我在 Eclipse 中使用 Egit 进行版本控制。我想要两个远程 Git 存储库,一个是 Github,另一个是 Heroku。前者供系统开发团队使用,后者仅用于部署。我按如下方式设置 git config
文件,但它不适用于两个 Remote 。
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "github"]
url = https://github.com/yltang52/airbus.git
fetch = refs/heads/master:refs/remotes/origin/master
push = master:refs/heads/master
[remote "heroku"]
url = https://git.heroku.com/airbus.git
push = master:refs/heads/master
[branch "master"]
remote = github
merge = refs/heads/master
ps。 yltang52
是 github 用户名,airbus
是项目名称。
问题之一是 Git 建议将 .git
目录放在项目根目录之外,这就是我现在正在做的事情。但是,Heroku 要求将该目录放置在项目根目录中。
当我在项目根目录中创建.git
目录时(根据Heroku的部署流程),我可以将项目部署到Heroku。但是当我尝试提交并推送到 Github 时,我的所有文件都被标记为提交。显然,两个 .git
副本不能一起工作。
我想将 Heroku 部署集成到 EGit 中。有什么解决办法吗?
最佳答案
直接使用与 Heroku 兼容的 Eclipse 项目会更容易,然后添加 GitHub 远程存储库引用。
这就是“How to push to multiple remote Git repositories using 1 Eclipse operation (killing 2 birds with 1 stone)”中描述的内容,使用:
这应该会给你一个已经配置了heroku远程url的heroku应用程序,并且你可以为其配置这些远程url:
您可以添加推送 URL(到 GitHub 存储库和 heroku):
(您可以用同样的方式配置Fetch)
从那里,“推送到上游”将推送到两者:
关于git配置: one fetch and two push destinations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27791189/