【问题标题】:How to "overwrite" in a single commit a git repo with another repo如何在单个提交中“覆盖”一个 git repo 和另一个 repo
【发布时间】:2014-09-20 10:59:22
【问题描述】:

我们有两个独立的 git 存储库,我们称它们为 DEV 和 LIVE。很多提交发生在 DEV 中。有时,我们希望在一次提交中使用 DEV 并用它覆盖 LIVE(不保留整个历史记录并在 LIVE 中查看所有历史提交)。

最简单、最安全的方法是什么?

【问题讨论】:

    标签: git github controls version


    【解决方案1】:

    您可以维护一个“发布”分支,您可以使用它从 DEV 推送到 LIVE

    您需要做的所有事情(当您想要更新 LIVE 时)就是将 master 合并到 release(生成一个 commit),然后推送该 release 分支。

    git remote add LIVE /url/to/LIVE/repo.git
    git fetch LIVE
    git checkout master
    
    # would work if there were already a release branch in LIVE
    git branch -u LIVE/release release master
    # otherwise, just create a local one
    git branch release master
    
    # ... do some commit
    
    # when ready to deliver
    git checkout release
    git merge master
    
    # first push to LIVE
    git push -u LIVE release
    # if there were already a release branch in LIVE
    git push
    

    【讨论】:

    • 非常感谢 VonC!我是 Git 新手,请您列出我需要使用的命令吗?
    • @AntoineA。当然,我已经用请求的命令编辑了答案。这个想法是保留一个发布分支以记录发布(作为一个合并提交)。
    • 感谢 VonC!为了清楚起见,这些命令将在哪个 repo 中?
    • 在 DEV 中,在推送到 LIVE 之前
    • 最后一行是从 DEV 推送到 LIVE 的吗?我们不应该用从 DEV 创建的遥控器替换 'origin' 到 LIVE 吗?
    猜你喜欢
    • 2011-06-07
    • 1970-01-01
    • 2011-11-01
    • 2014-01-26
    • 1970-01-01
    • 2017-06-03
    • 2014-06-13
    • 2023-02-10
    • 2014-02-16
    相关资源
    最近更新 更多