Reputation: 57
We have a repo in github We are using sourceTree as gitclient
Is there a way to reset the repo to an old commit?
I have tried to do it locally with sourcetree, and I can go as far as resetting locally to the old commit in question.
However, when I try to push to the remote repo to reflect the local changes, it tells me that that is not possible because the remote repo is ahead of the local repo
Any idea?
Cheers
Upvotes: 2
Views: 2044
Reputation: 14089
I think the best way would be to use git revert
to make a new commit for the revert instead of forcing a push where you delete history.
git revert is used to record some new commits to reverse the effect of some earlier commits (often only a faulty one).
Upvotes: 0
Reputation: 9197
Git is stopping the push because it would abandon history on the remote. This is usually a bad thing, so git is helping you avoid a mistake. If you really want to push a local branch is a way that abandons history, you need to add the -f
flag.
git push -f <remote> <branch>
It sounds like this is what you want, but be careful. Check the output of
git fetch <remote>
git log <remote_branch> --not <local_branch>
and make sure that you really do want to abandon all of those commits before you do a force push.
Upvotes: 2