【问题标题】:Replace remote git repo (Heroku)替换远程 git repo (Heroku)
【发布时间】:2012-01-06 02:53:42
【问题描述】:

我是 git 和 heroku 的新手。

我在 heroku 上创建了一个应用,将一些文件推送到了 repo。

现在我想用另一个文件夹中的新内容完全替换这个应用程序的存储库(并在该文件夹中有一个 .git 存储库)。这样做的正确方法是什么?

【问题讨论】:

    标签: git heroku


    【解决方案1】:

    如果你想用新的第二个 repo 的历史完全替换你已经推送的提交历史,你需要做的就是:

    git remote show heroku in the first repo
    cd /path/to/seconf/git/repo
    git remote add heroku <heroku_repo_address_from_previous_command>
    # for instance: git remote add heroku git@heroku.com:appname.git
    git push --force heroku master
    

    这会将远程heroku 存储库的master 分支替换为您的第二个存储库的master 分支。但这会丢失(或至少在远程 repo 的 reflogs 中保留一段时间)前 repo 的 master 分支的历史记录。

    假设您可以按照Heroku quick start pageHeroku Deploying with git page 重复使用已创建的heroku 凭据。

    【讨论】:

    • 谢谢。是 --force 选项让 100% 的受让人新的主分支不会与服务器上的旧分支合并,而只是替换它?从 docs 这并不明显(“这个标志 [-f,--force] 禁用检查。这可能导致远程存储库丢失提交;小心使用它。”)
    • @WHITECOLOR:是的,不会有任何合并。
    • 只需要使用“原力”
    猜你喜欢
    • 1970-01-01
    • 2013-12-03
    • 2012-12-09
    • 2021-07-03
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-18
    相关资源
    最近更新 更多