简体   繁体   中英

How can I resolve non-fast-forward updates error when pushing app to heroku?

I am kind of stuck here while trying to update my first node.js app in heroku.

The initial version of the app is deployed successfully but now when I try to deploy the modified app it's giving me some problem. Here is the command and the output

> git push heroku master
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:....git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the 'Note 
about fast-forwards' section of 'git push --help' for details.

The git status command display's the following :

On branch master
Your branch is ahead of 'origin/master' by 1 commit.

On heroku it makes sense to do:

git push -f heroku master

since you are not using it as a revision system but as a deployer.

The obvious thing you should do is get your local repositiory in sync with the remote one. As the error message text shows, this is probably as simple as running a pull:

git pull

If that isn't enough to clear up your problem, you probably need to rebase your local work on the remote branch. If you only have on remote (your heroku repository) you can probably do this as simply as:

git rebase

With that done, you should then be able to push without introducing a conflict in the remote repository.

Note that you typically do not want to use the rebase function if any of your local commits have been pushed any remote repositories. That will only introduce a puzzling set of circular changesets.

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