Heroku:! [拒绝]主人 - >主人(非快进)

时间:2015-05-30 23:22:29

标签: ruby-on-rails git heroku

每当我尝试将rails app推送到heroku时,我都会得到错误。我该怎么做才能解决这个问题?我做了git init,git add。,git commit -m"完成"和git push heroku master

To https://git.heroku.com/shuabe.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/james.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

3 个答案:

答案 0 :(得分:5)

有人承诺,所以你必须更新你的brach width git pull才能更新。

git fetch --all --prune
git pull origin master

Fetch将更新您的所有分支机构& pull会将最新内容存入您的主分支。

如果你读错了它会解释你该做什么。

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes

更详细

您正在尝试推送到远程分支,该分支有一些您在分支中没有本地提交的提交。为了推送到non-fast-forward存储库,您的分支必须具有来自远程存储库的最新更新。

如何获取最新更新?

git fetch --all --prune

此命令将获取整个远程存储库的所有内容,并将更新.git文件夹中的内部git存储(pack和amp; index文件)。

git pull origin master

此命令将获取&将远程分支合并到您的本地分支(master),然后您就可以推送您的更改。

答案 1 :(得分:1)

我通过:

git pull heroku master   

之后,控制台显示:

From https://git.heroku.com/myweb
 * branch            master     -> FETCH_HEAD
Auto-merging views/layout.hbs
CONFLICT (content): Merge conflict in views/layout.hbs
Auto-merging views/ads/list.hbs
Auto-merging controllers/users.controller.js
CONFLICT (content): Merge conflict in controllers/users.controller.js
Auto-merging config/db.config.js
CONFLICT (content): Merge conflict in config/db.config.js
Automatic merge failed; fix conflicts and then commit the result.

我接受了所有更改,然后:

git push heroku master 

答案 2 :(得分:1)

您还可以使用force参数。

git push --force heroku yourbranch:master