存储库不为空的 Heroku "cloned an empty repository" 消息

Heroku "cloned an empty repository" message for a repository that isn't empty

考虑到 Heroku/Github 问题,我尝试改用 Heroku CLI 发布说明。

它适用于我管道中的一个环境,但不适用于另一个环境。它 returns“您似乎克隆了一个空存储库。”当我 运行 以下内容时。

heroku git:clone -a xxxxxx-release 
Cloning into 'xxxxxx-release'...
warning: You appear to have cloned an empty repository.

此 运行ning 环境中有大量代码。我看了一下这个 - https://help.heroku.com/XOBUHLKQ/why-do-i-see-a-message-you-appear-to-have-cloned-an-empty-repository-when-using-heroku-git-clone - 但它说答案必须使用我们不使用的按钮。我试图在那里搞混,但似乎无法为当前应用程序制作按钮,只能为新应用程序制作按钮。

S.O。请注意,我可以尝试添加一个文件并提交它,但这也会 returns 一个错误:

remote: !   Push rejected to xxxxxx-release.        
remote: 
To https://git.heroku.com/xxxxxx-release.git
  ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/xxxxxxx-release.git'

我现在不知道如何发布到这个分支。在此先感谢您的帮助。

不要从 Heroku 克隆。

由于您一直在通过 GitHub 进行部署,因此您应该已经有一个本地副本。只需使用:

cd project-directory/
heroku git:remote -a <YOUR_APP_NAME>  # Add a remote for your Heroku-hosted app
git push heroku  # Assuming you're already on main and want to deploy that version

如果出于某种原因,您没有本地副本,请从 GitHub 克隆,然后按上述步骤进行操作。

从 Heroku 克隆/拉取 isn't meant to be part of your regular workflow:

A Heroku app’s Git repository is intended for deployment purposes only. Cloning from this repository is not officially supported as a feature and should be attempted only as a last resort. Do not use this repository as your app’s canonical “origin” repository. Instead, use your own Git server or a version control service such as GitHub.

从 Heroku 克隆时得到空存储库的原因是 GitHub deploys don't populate the Heroku-hosted repository:

Does the GitHub integration sync to my Heroku-hosted Git repo?

For apps with GitHub integration enabled, Heroku does not sync the contents of the GitHub repo to the Heroku-hosted repo. Instead, Heroku pulls source directly from GitHub.