1

So I made some changes to my git repo and commited them. Put them on server and now the server crashes. I did a git reset Hard to an earlier commit "12345". I then found the issues and fixed. So now I want to back to the last commit "abcd".

Example

1st commit 

....

commit "12345"

....

commit "abcd"

I did a reset Hard to "abcd" then made my fixes to the code. But now when I try to push I get this error.

"... prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. "

So how do I scrap everything and get local and remote back to commit "abcd"?

===== UPDATE ===================

I tried git push and I get "Everything up-to-date".

UPDATE:

OK here is a visual graph of my commits

* 731e9        (HEAD, origin/beta-stag, beta-stag) <--- last commit HERE
* 5c82f        More whitespace
* 8939c        More whitespace test
* f3bd1        Added whitespace after git pull origin beta stag and then a git fetch. Now adding whit
* d2336        did a pull origin beta-stag as it will NOT let me pushbs
* 5a2f9        After reset hard. This commit is after I went to the end commit minus whitespace one. The
* 18393        Added whitespace to see if my revert will let me push
| * 36e9d0f      (origin/beta, heroku/master, beta) removed assigned_dealer2_id
| * 75203      removed @ar.assigned_dealer2 refernces
| * 784a6      removed check for service tier
| * 77789      removed hidden field can not view call history
| * ee6d8      First commit not from beta-stag
| *   55905    Merge branch 'beta-stag' into beta
| |\  
| | * cd7c4    Random changes
| * |   e6d92  Merge branch 'beta-stag' into beta
| |\ \  
| | |/  
| | * 4dc81    (I NEED TO HERE!!! Damn everything else on origin/master)Changed dealer min to 1 for any high level deliveries like bolt 
| | * d73f5    Added name so when dealer 2nd is selected we show by name not id
| | * f3afc    Switched to dealer email in the 2nd dealer dropdown as some dealers have two phones.
........
1st commit here
jdog
  • 10,351
  • 29
  • 90
  • 165
  • Possible duplicate of [Force "git push" to overwrite remote files](http://stackoverflow.com/questions/10510462/force-git-push-to-overwrite-remote-files) –  May 02 '17 at 20:55
  • No this is not a duplicate. I tried git push -f and is says "Everything up-to-date" – jdog May 02 '17 at 21:02
  • Please see above visual graph of commits. I need to be back here with the two branches ( | | * 4dc81 (I NEED TO HERE!!! Damn everything else on origin/master)Changed dealer min to 1 for any high level deliveries like bolt) – jdog May 02 '17 at 21:23
  • Your edit suggests you never did the "git reset", but you may have done that, then re-pulled from the remote and got back to the last commit. At any rate, its effect didn't stick. Run "git reset --hard 4dc81" again, then "git push -f". –  May 02 '17 at 21:24
  • Before I do that. Let me say I am the only developer so I do NOT have to worry about anyone else. So how can I delete (in the graph above) everything up above (| | * 4dc81 ). Like it did NOT even happen? – jdog May 02 '17 at 21:27
  • For a local branch, that's exactly what git reset --hard is for. For a remote branch, that's exactly what git push --force is for. –  May 02 '17 at 21:41

0 Answers0