【发布时间】:2012-01-06 02:53:42
【问题描述】:
我是 git 和 heroku 的新手。
我在 heroku 上创建了一个应用,将一些文件推送到了 repo。
现在我想用另一个文件夹中的新内容完全替换这个应用程序的存储库(并在该文件夹中有一个 .git 存储库)。这样做的正确方法是什么?
【问题讨论】:
我是 git 和 heroku 的新手。
我在 heroku 上创建了一个应用,将一些文件推送到了 repo。
现在我想用另一个文件夹中的新内容完全替换这个应用程序的存储库(并在该文件夹中有一个 .git 存储库)。这样做的正确方法是什么?
【问题讨论】:
如果你想用新的第二个 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 page 和Heroku Deploying with git page 重复使用已创建的heroku 凭据。
【讨论】: