3

My story:

I am working on a project and by accident i commited all changes under same commit message to Github, but this wasn't the problem, i used

git reset --soft HEAD~1

and everything solved locally, now i am trying to push that to Github again but i got this message always:

error: failed to push some refs to 'https://github.com/dr-coder/Chat-App.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

How to return my Github repo to push state again??

Code Eagle
  • 1,293
  • 1
  • 17
  • 34
  • 1
    I think the Git history was altered by you locally. You either need to fix the history locally or force push to the remote repo (which is VERY dangerous) – Joshua Jul 27 '20 at 01:41
  • but the problem is not locally i think, the problem in github, it has one more commit that i need to revert, but i don't know how, i tried from the website but both git and github are new to me – Code Eagle Jul 27 '20 at 01:45
  • 1
    If you're the only dev who is working on that repo, then you can do a force push which will resolve your issue – Joshua Jul 27 '20 at 02:00
  • @konekoya Thank you this worked , you can add your answer if you want – Code Eagle Jul 27 '20 at 02:12
  • It's okay, I actually not really sure if it would work or not :) – Joshua Jul 27 '20 at 02:31
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+tip+of+your+current+branch+is+behind – phd Jul 27 '20 at 11:29

1 Answers1

3

As you’re the only one working on the repo, you can do a:

git-push --force

If you’re not, you can revert the old changes using in the following:

git checkout -b old-state COMMIT

This will create a branch with the commit you want to revert to.