部署重写的Github / Heroku应用程序
问题描述:
我有一个应用程序在Heroku / Github上运行,但最近完全从头开始重建 - 我想保留旧的存储库名称,用新代码替换实时代码的最佳方法是什么?
I have an app that is live on Heroku/Github, but recently completely rebuilt it from scratch - I want to keep the old repository name, what is the best way to replace the live code with the new code?
答
cd old_version
git rm -rf .
git commit -m "Removing the old code"
git remote add version2 "/path/to/new_version/.git"
git pull version2 master
这应该完全保留两个历史记录,并且将新版本作为原始回购的头部。我建议您在尝试之前备份回购。
That should fully preserve both histories and have the new version be the HEAD of orginal repo. I would recommend backing up repos up before you try this.