【问题标题】:Django Heroku app moved to new computer - error on git push heroku masterDjango Heroku 应用程序移至新计算机 - git push heroku master 上的错误
【发布时间】:2021-01-16 14:12:21
【问题描述】:

我最近将部署在 Heroku 上的 Django 项目移到了新计算机上。通过在我的新计算机上克隆我的存储库。我现在已经在新计算机上对项目进行了更改,并已提交到我的 GitHub 存储库。

现在我已将我的项目 GitHub 存储库以及 Heroku 远程存储库添加到远程,我可以在运行 git remote -v 时看到它:

heroku  https://git.heroku.com/myapp.git (fetch)
heroku  https://git.heroku.com/myapp.git (push)
origin  https://github.com/username/repo.git (fetch)
origin  https://github.com/username/repo.git (push)

现在,当我想提交新的更改时,我会这样做:

git add .

然后

git commit -m "commit message" - 哪个提交到我的 GitHub 存储库?不知道对不对

现在当我想使用命令git push heroku master 推送到heroku master 我收到以下错误:

 ! [rejected]          master -> master (fetch first)
    error: failed to push some refs to 'https://git.heroku.com/myapp.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我还添加了密钥,使用 heroku keys:add,因为我的新计算机上没有任何密钥,所以我创建了一个新的,现在我可以在运行 heroku keys 时看到它。

我只想将我对存储库所做的新更改推送到 heroku master。我怎样才能推动新的变化?使用命令git push heroku master?

我试过这些命令:

  1. git push heroku master -f 这给了我错误:! [remote rejected] master -> master (pre-receive hook declined)

  2. git push heroku +HEAD:master

这给了我错误:! [remote rejected] master -> master (pre-receive hook declined)

  1. 我尝试了git fetch,但仍然遇到同样的错误

编辑

我跑了git fetch heroku,但是,现在我得到一个新的错误:

 ! [rejected]          master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/myapp.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details

我尝试过使用git push -f heroku master,但是,我得到了错误: master -> master (pre-receive hook declined)

【问题讨论】:

    标签: django git github heroku


    【解决方案1】:

    试试这个:

    git pull
    git add .
    git commit -m "commit message"
    git push heroku master
    

    此外,请查看 here `git commit -m "commit message" 的作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-03
      • 2016-12-26
      • 1970-01-01
      • 1970-01-01
      • 2018-11-05
      • 2016-02-19
      • 2019-10-14
      • 2014-07-05
      相关资源
      最近更新 更多