1

I used the following three commands to push the changes to an already existing app but the changes are not being reflected

$ git add .
$ git commit -m "changes"
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
$ git push heroku master

And I get:

To git@heroku.com:sleepy-oasis-7771.git ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:sleepy-oasis-7771.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.

and no changes are reflected in the app

Hauleth
  • 22,873
  • 4
  • 61
  • 112
puneets
  • 43
  • 3

1 Answers1

2

Your push was ! [rejected]. That's why no changes take effect.

As the message indicates:

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.

This refers you to further documentation, visible on your local machine or online. Again, as the message indicates, a git pull (and its resulting merge) will fix this issue.

One way to avoid this problem is by using a rebase workflow instead of a merge workflow. Do your development in a feature branch, and when you're ready to merge, pull master, rebase the feature branch, re-run your test suite, and then merge.

Also, please read your error messages.

willglynn
  • 11,210
  • 48
  • 40