Git reset remote - resetting remote to a certain commit

701    Asked by Aryangupta in SQL Server , Asked on Jul 6, 2021

- I want to discard all changes done after commit . So I did:

git reset --hard 

Now I want to do the same with my remote. How can I do this? I have done some commits (and pushes) after and I just want to discard them all. It is just something that went terribly wrong in the way and I don't want to make it worse than it is already. 

I basically want to rewind my origin/master to

Answered by Arun Sharma

Use the following commands to solve git reset remote origin:

git reset --hard 
 git push -f origin master

Here assuming origin as your remote and master as your branch.

However, you should avoid doing this if anyone else is working with your remote repository and has pulled your changes. In that case, it would be better to revert the commits that you don't want, then push as normal.

From your query it's clear that you have already used git reset --hard to reset your master branch, you may need to start by using git reset --hard ORIG_HEAD to move your branch back to where it was before.

I hope this will help you resolve git reset remote origin.



Your Answer

Interviews

Parent Categories