ruby-on-rails - 部署重写的 Github/Heroku 应用程序

标签 ruby-on-rails ruby-on-rails-3 git heroku github

我有一个在 Heroku/Github 上运行的应用程序,但最近完全从头开始重建它 - 我想保留旧的存储库名称,用新代码替换实时代码的最佳方法是什么?

最佳答案

Michael 略有不同的 answer :

git branch -M master old_master
git rm -rf .
git checkout --orphan master
git remote add version2 "/path/to/new_version/.git"
git pull version2 master

(像往常一样,先备份所有内容)

如果您使用 git1.7.2+ , 你可以使用 git checkout --orphan :

Similar to -b, --orphan creates a new branch, but it starts without any commit.
After running "git checkout --orphan newbranch", you are on a new branch "newbranch", and the first commit you create from this state will start a new history without any ancestry.

When creating a branch whose trees have no resemblance to the ones from the original branch, it may be easier to start work on the new branch by untracking and removing all working tree files that came from the original branch, by running a 'git rm -rf .' immediately after running "checkout --orphan".

您可以避免在相同 分支上有两个不同的历史记录,并在一个特定的提交时突然更改。
相反,您保留几个具有不同历史的根分支
但这意味着重写 master 的提交历史,考虑到您只需要以前的历史供引用和存档,这并不是那么糟糕。

关于ruby-on-rails - 部署重写的 Github/Heroku 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7411392/

相关文章:

ruby-on-rails - 限制查询结果

ruby-on-rails - 将模型管理添加到 Active Admin - Rails 3

mysql - 在 Ruby on Rails 中执行 SQL 文件以导入数据库

ruby-on-rails-3 - 将 slider 添加到 Rails 应用程序

git - 如何从 vscode 中删除同步的远程存储库

mysql - Rails 4 通过按货币和计数查询总金额来加入组

ruby-on-rails - rspec/capybara : how to simulate incoming POST requests?(机架测试不起作用)

ruby-on-rails-3 - rspec 中的 `puts response` 堆栈级别太深

c++ - cmake:在主 cmakelists 中使用之前从 git 检索库

git - 一个 git repo 可以有多少个 HEAD?