git配置: one fetch and two push destinations

标签 git heroku egit

我在 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:

https://lh5.googleusercontent.com/s0BexPSV1e7c_BEJ3aMlKxnLx1pO7wLgixSnvRoFcuE8fw2Jl99zaY2csJbSfVRg_c3Mnq6RRWjChCsF-apW3nnk39iSrrgeIDn6RzIsXCJDCp6CqEP-PCXRPQ

您可以添加推送 URL(到 GitHub 存储库和 heroku):

https://lh4.googleusercontent.com/UtOL9MAzW35ZivE2lp-OQFEacg6Jl6avPX65Q79Na8raExYZcDhTXb5kTzM1MfzRVh54_o1wSCt73VoxYxLm9xZGq5uXKtxm_A6PQu2QOUe_si7FyB8NYSCkRg

(您可以用同样的方式配置Fetch)

从那里,“推送到上游”将推送到两者:

https://lh3.googleusercontent.com/Rp1r1qmjeZjAs5ZSw0TfR426m1buWdX31SaWTwLpQdW-s5Ri5QSKMf__T1cZNZ4Uc_ImcAz_fGqhQQ0F5Xodax6BJKOqqF0iepV6LNBtvSyVlFnqA1PzJ9v21A

关于git配置: one fetch and two push destinations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27791189/

相关文章:

git - 我应该为每个工作站生成新的 SSH key 对还是重复使用一个 key 对?

xcode - 如何使用Swift Package Manager从 repo 中排除文件/文件夹?

git - Qt 翻译和 git 的最佳实践

python - 是否可以在 heroku 上运行 scrapy?

bash - 搜索整个 git 子命令、指南和概述手册页

javascript - 无法从 Javascript 应用程序访问 Heroku Config Vars 中的 API key

python - django 应用程序在 heroku TypeError : expected str, bytes 或 os.PathLike 对象(而不是函数)上崩溃

Eclipse Egit 和 GitHub 身份验证弃用

eclipse 总是提示远程 git 不支持智能 http 推送

eclipse - 无法使用Eclipse key 文件