通常,您可以使用heroku git:clone
命令检索Heroku应用程序的代码。如果使用Heroku'Deploy to Heroku'按钮部署应用程序,则克隆会导致空回购(有关详细信息,请参阅here)。
检索上面链接中描述的代码的方法假定原始repo仍然存在。
如果原始仓库不再存在,我将如何检索代码?
为了做到这一点,我使用了以下命令:
mkdir -p {app name} && heroku run "tar -cz * | base64 -w 0" --app {app name} | base64 -D | tar -xzf - -C {app name}
这是来自MacOS中的bash,因此一些本地bash命令参数在其他版本的Unix中可能会有所不同。
根据您的应用程序,您可能需要在tar -cz
命令中排除某些目录(例如--exclude='./node_modules'
)
您可以heroku run bash
并手动复制代码。