简体   繁体   中英

Heroku: ! [rejected] master -> master (non-fast-forward)

I get and error whenever I try to push rails app to heroku. What do I do to fix this? I did git init, git add., git commit -m "complete", and 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.

Someone has committed so you have to update your brach width git pull in order to be up to date.

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

Fetch will update all your branches & pull will grab the latest content into your master branch.

If you would read the error it explaining you what to do.

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

More detailed

You are trying to push to a remote branch which has some commits that you don't have them locally in your branch. In order to push to a non-fast-forward repository you branch must have the latest updates from the remote repository.

How to grab latest updates?

git fetch --all --prune

This command will grab all the content of the whole remote repository and will update the internal git storage (pack & index files) inside the .git folder.

git pull origin master

This command will fetch & merge the remote branch into your local branch ( master ) and after that you will be able to push your changes.

你也可以使用force参数。

git push --force heroku yourbranch:master

I fixed by:

git pull heroku master   

After that, console shows:

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.

I accepted every change, and after that:

git push heroku master 

git pull heroku main

Then

git push heroku main

The above commands worked for the question.

  • Then I got another error: your account has reached its concurrent builds limit (pre-recieve hook declined).

I resolved that with:

heroku restart

PS: git pull heroku main then git push heroku main should work straight up for heroku accounts that haven't reached builds limit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM