Updates were rejected because the tip of your current branch is behind?

Viewed 358

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

1 Answers

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.

Related