[英]Heroku - Error during git push/deployment, The same version of this code has already been built
I have a problem deploying my springboot application to Heroku.我在将 springboot 应用程序部署到 Heroku 时遇到问题。 After running
git push heroku master
, I am encountering the error below:运行
git push heroku master
后,我遇到以下错误:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.350 s
[INFO] Finished at: 2020-12-22T06:33:14Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project audit: Fatal error compiling: invalid target release: 11 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :audit
remote: ! Push rejected, failed to compile Java app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote: !
remote: ! We have detected that you have triggered a build from source code with version 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to tesda8app.
I am clueless into why this error occurred.我不知道为什么会发生这个错误。 I have two remote repositories on which I push my code, one from Heroku and one in Github.
我有两个远程存储库,我在其中推送代码,一个来自 Heroku,一个来自 Github。 I have tried the command below based from the answer from this question, Heroku: If you are developing on a branch and deploying via git you must run:
我已经根据这个问题的答案尝试了以下命令, Heroku:如果您正在分支上开发并通过 git 进行部署,则必须运行:
git push heroku master:main
But still the error persists.但错误仍然存在。 Is there any command that I could try on the Heroku CLI to solve this problem?
我可以在 Heroku CLI 上尝试任何命令来解决这个问题吗?
After some few tries, I was thinking that the cause of the problem was maybe an interrupted git push heroku master
command, which was then proceeded by a re-execution of the same command, causing the error below:经过几次尝试,我认为问题的原因可能是中断的
git push heroku master
命令,然后重新执行相同的命令,导致以下错误:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote: !
remote: ! We have detected that you have triggered a build from source code with version 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
So what I did was, I pushed another commit, then retried the same command git push heroku master
, which resulted to a successful deployment.所以我所做的是,我推送了另一个提交,然后重试了相同的命令
git push heroku master
,从而成功部署。
Also, shoutout to RainXCat's answer and insights , now I know Heroku does not allow two git repositories on the same directory/folder.另外,对RainXCat 的回答和见解大喊大叫,现在我知道 Heroku 不允许在同一目录/文件夹上存在两个 git 存储库。
I was having the same error on the same day as you, I don't know if it's the answer you are looking for but I somehow solved the issue.我和你在同一天遇到同样的错误,我不知道这是否是你正在寻找的答案,但我以某种方式解决了这个问题。 I was making a Django-Rest-Api.
我正在制作一个 Django-Rest-Api。
you have created two git repositories in the same folder/directory and pushed the same code into their head and somehow Heroku doesn't want you to do that.您已经在同一个文件夹/目录中创建了两个 git 存储库,并将相同的代码推送到他们的头脑中,并且不知何故Heroku不希望您这样做。 remember no two git repo on the same level .
记住在同一级别没有两个 git 回购。
git push heroku master:main
thinggit push heroku master:main
Heroku only deploy your code from the main/master branch so if you are pushing from other than master, you have to use it like git push heroku <new branch>:main
, using :main
with master
is meaningless(same). Heroku 仅从 main/master 分支部署您的代码,因此如果您从
master
以外的地方推送,则必须像git push heroku <new branch>:main
一样使用它:main
是无意义的。
I don't remember exactly where I get this but you have to make a new git branch , do我不记得我从哪里得到这个但你必须创建一个新的 git 分支,做
git branch <new branch>
git checkout <new branch>
git add .
git commit -am "commit message"
git push heroku <new branch>:main
but it's giving the same error because you still have two git repo in your directory.但它给出了相同的错误,因为您的目录中仍然有两个 git 存储库。
you can remove the repo like this.你可以像这样删除回购。
rm -rf .git
I suggest you to do the experiment on a temporary copy.我建议您在临时副本上进行实验。
All I did was copy all the files inside, made a new folder with a different name, pasted all files, deleted the old, and rename the new to the old one.我所做的只是复制里面的所有文件,创建一个不同名称的新文件夹,粘贴所有文件,删除旧文件,并将新文件重命名为旧文件。 by doing this you will have a git free directory then you can use the
git init
method to simply make a new repo.通过这样做,您将拥有一个 git 空闲目录,然后您可以使用
git init
方法来简单地创建一个新的 repo。
git init
heroku create
git add .
git commit -am "initial commit"
git push heroku master
This should resolve the error, It's solved for me so it's unlikely that I am going to work on it anymore but if my answer is not right in any manner please do tell me.这应该可以解决错误,它已经为我解决了,所以我不太可能再处理它了,但是如果我的答案在任何方面都不正确,请告诉我。
this worked for me!这对我有用!
git branch <new branch> git checkout <new branch> git add. git commit -am "commit message" git push heroku <new branch>:main git push --set-upstream heroku <new branch>
this worked for me.
这对我有用。
I deleted my package-lock.json file and do the following again我删除了我的 package-lock.json 文件并再次执行以下操作
the purpose is to clear your build cache目的是清除您的构建缓存
Install the Heroku CLI Download and install the Heroku CLI.安装 Heroku CLI 下载并安装 Heroku CLI。
If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.如果您还没有,请登录您的 Heroku 帐户并按照提示创建新的 SSH 公钥。
$ heroku login
Clone the repository Use Git to clone projects' source code to your local machine.克隆存储库使用 Git 将项目的源代码克隆到本地计算机。
$ heroku git:clone -a project
$ cd project
Deploy your changes Make some changes to the code you just cloned and deploy them to Heroku using Git.部署您的更改 对您刚刚克隆的代码进行一些更改,然后使用 Git 将它们部署到 Heroku。
$ git add .
$ git commit -am "make it better"
$ git push heroku master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.