0

I did a get reset --hard SHA I then updated my Ruby version, did a bundle update and made some local changes. Then did a commit. Now that I want to push the branch to GitHub I am getting the following error and not sure why?

(non-fast-forward)
error: failed to push some refs to 'https://github.com/jgervin/stat-api.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.

enter code here

UPDATE:

I did a

git push -f

It said it did the force, but when I try to push again it says the same thing.

So I did another

git push -f

Says everything up to date

So did a git push and same error?

jdog
  • 10,351
  • 29
  • 90
  • 165
  • Possible duplicate of [Git non-fast-forward rejected](https://stackoverflow.com/questions/5667476/git-non-fast-forward-rejected) – bmargulies Dec 07 '18 at 04:04
  • 2
    are you on the master branch? Try `git push origin master -f` - that's the command from memory - warning: YOU WILL LOSE EXISTING COMMITS ON YOUR MASTER BRANCH!! – BenKoshy Dec 07 '18 at 04:19
  • I am not on master, but a staging branch. Here is the error I get when pushing to Heroku. ! [rejected] beta-staging -> master (non-fast-forward) – jdog Dec 07 '18 at 04:21

1 Answers1

2

Now that I want to push the branch to GitHub

That is not the same as heroku:

Here is the error I get when pushing to Heroku. ! [rejected] beta-staging -> master (non-fast-forward)

Check your git remote -v remote names.
If origin refers to GitHub, you did your push --force already.
You might have to do the same to heroku, if you want the same history there.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250