我正在Heroku上进行托管。当我提交(push)时:
git push master Heroku
我遇到了一个错误:
error: src refspec master does not match any.
error: failed to push some refs to 'git@heroku.com: etc ...'
我正在Heroku上进行托管。当我提交(push)时:
git push master Heroku
我遇到了一个错误:
error: src refspec master does not match any.
error: failed to push some refs to 'git@heroku.com: etc ...'
heroku https://git.heroku.com/yourapp.git (获取) heroku https://git.heroku.com/yourapp.git (推送)
如果没有,则设置远程 - git remote add heroku git@heroku.com:MyApp.git(在旧版本的Git中)或heroku git:remote -a example-app(在新版本的Git中)
git push heroku master(旧版Git) git push heroku main(新版Git)
请确保您推送的应用名称与Heroku中的相同。
如果上述解决方案无效,请检查隐藏的.git文件夹。在.git文件夹中,检查名为packed-refs的文件, 它应该有一个哈希键引用到refs/remotes/heroku/main。 如果没有,则可以按照以下步骤操作:
要获取Heroku应用程序列表,请运行以下命令 heroku apps
我也遇到了同样的问题。
对我来说,问题出在我没有正确地登录 git。
在将代码推送到主分支之前,必须首先使用命令 git commit -m "My first commit"
进行初始提交。
当您尝试执行此操作时,可能会得到以下响应(就像我得到的一样):
git: fatal unable to auto-detect email address (got "some wrong email").
如果您得到了这个响应,那么现在必须使用以下命令输入所需的 git 电子邮件和用户名:
git config --global user.email "you@example.com"
git config --global user.name "Your Username"
完成后,请再次尝试推送命令
git push heroku master
现在应该可以正常工作。
我在将本地存储库的副本推送到GitHub存储库后遇到了这个问题。
在此之前,从我的本地存储库运行git push heroku master
以部署到Heroku一直很顺利。
然而,在推送到GitHub之后,git push heroku master
开始出现error: src refspec master does not match any
错误消息,我不得不使用git push heroku main
才能成功部署。
显然,将副本推送到GitHub会将本地存储库的分支名称从master
更改为main
。
package-lock.json
和yarn.lock
。删除其中一个解决了问题。以下是错误信息: ! Two different lockfiles found: package-lock.json and yarn.lock
Both npm and yarn have created lockfiles for this application,
but only one can be used to install dependencies. Installing
dependencies using the wrong package manager can result in missing
packages or subtle bugs in production.
- To use npm to install your application's dependencies please delete
the yarn.lock file.
$ git rm yarn.lock
- To use yarn to install your application's dependences please delete
the package-lock.json file.
$ git rm package-lock.json
commit
操作? - sebgit config --global
。 - Memphis Menggit push heroku main
。 - Sam Murphy