开发者

GitHub to Heroku Commit Error

Am using Aptana Studio 3 and Heroku for a RoR website project. When I push my site to Heroku after a 'commit' via GitHub I keep getting this error. Have searched everywhere but can't find a simple solution that I can follow. Any advice what has happened and how to reslove? Thx.

User$ git push heroku master
To git@heroku.com:xxxxxx.git
! [rejected]        master -> master (non-fast forward)
error: failed to push some refs to 'git@heroku.com:xxxxxx.git'
To prevent you from losing history, non-fast-forward updates were rejected.
Merge the remote changes before pushing again.
See 'non-fast forward' section o开发者_JAVA百科f 'git push --help' for details.
User$ 

I tried this suggestion as per below from @SkillDrick and got this plus the error at the end:

User$ git merge heroku/master master
usage: git merge [options] <remote>...
or: git merge [options] <msg> HEAD <remote>

-n                    do not show a diffstat at the end of the merge
--stat                show a diffstat at the end of the merge
--summary             (synonym to --stat)
--log                 add list of one-line log to merge commit message
--squash              create a single commit instead of doing a merge
--commit              perform a commit if the merge succeeds (default)
--ff                  allow fast forward (default)
-s, --strategy <strategy>
                      merge strategy to use
-m, --message <message>
                      message to be used for the merge commit (if any)
-v, --verbose         be more verbose
-q, --quiet           be more quiet



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


I had the same issue. A very simple solution would be to force the push anyways:

git push heroku master -f

Since heroku is just being used to deploy your App(and not for source control like origin/master) this should be fine.


For some reason your Heroku repo has diverged. You could do:

git fetch heroku
git merge heroku/master
git push heroku master

which will "Merge the remote changes before pushing again." Before you merge, maybe do git diff heroku/master to find out what's actually different.


Do a git pull and then do the git push


Like manojlds said, do a git pull first.

Actually before doing anything check your local repo if you have any changes.

git status

if there are none, do a git pull heroku master. If there are changes, either commit or stash them.(I'd say just stash them for now)

After you have pulled(hopefully without any conflicts), do a git push heroku master and you should be all set. If you have conflicts, resolve them first, commit, then push.

What basically happened is that your heroku repo has diverged from your current one. This happens mostly in the following scenario:

  1. UserA makes changes, pushes to heroku and your github repo.
  2. UserB pulls, makes changes, pushes to the heroku repo and forgets to push to github.
  3. UserA pulls from github and tries to push to heroku.

In that case, you are userA and that means you pulled something that wasn't in heroku.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜