1

I made some errors in my code and I need to do the following to reset it:

git reset --hard 0adf6cdaa45af6b0520de1a54d027be5f1a84f06

I also want to remove everything that has been committed after that. How would I do this to permanently reset the repository to this? That is, if I do $ git pull origin production, I want nothing to happen because the repository is 'at' the reset position.

1

3 Answers 3

2

I am assuming you are working by yourself and you have the luxury to discard all commits after that SHA1. Then you can overwrite history with git push force. Next time you do a git pull origin production, you should be 'at' the reset position.

git push --force

See also: Force "git push" to overwrite remote files

1

You need to push a new HEAD to github. I'm not sure it's allowed but it's called a forced push (search for --force).

git push --force

Make sure that all other developers that have this repository checked out do git pull after you've pushed. If they start to develop after a commit you've thrown away things will go bad.

0

Use git reset --hard 0adf6cdaa45af6b0520de1a54d027be5f1a84f06 to revert your code to your correct last commit. But, you need to make sure that every1 working in your project must take pull after your action.

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