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??

6
  • 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
    Commented Jul 27, 2020 at 1: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
    Commented Jul 27, 2020 at 1: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
    Commented Jul 27, 2020 at 2:00
  • @konekoya Thank you this worked , you can add your answer if you want
    – Code Eagle
    Commented Jul 27, 2020 at 2:12
  • It's okay, I actually not really sure if it would work or not :)
    – Joshua
    Commented Jul 27, 2020 at 2:31

1 Answer 1

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.

2
  • COMMIT is SHA??
    – Code Eagle
    Commented Jul 28, 2020 at 7:28
  • @CodeEagle yes it is
    – user12867493
    Commented Jul 28, 2020 at 8:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.