Reputation: 1283
I have a single branch (master) on my git repo. I have been pushing commits to my remote repo.
I now want to revert back to a previous commit, and start from there again.
I have run the following:
git reset --hard <commit hash>
Now the head is at my chosen commit, from here I want to push this chosen commit as the head to my remote master branch.
git push origin master
It won't work - error message stats
'Updates were rejected because a pushed branch tip is behind its remote counterpart.'
How do I checkout a previous commit locally, set the head to be at that commit and then push to my remote repo?
Thank you
Upvotes: 1
Views: 1723
Reputation: 148
The $ git reset --hard commit
part is okay, you just need to do $ git push --force origin master
Upvotes: 3