Revert changes pushed to github
May 7, 2020
May 7, 2020
Sometimes you have one of those moments where muscle memory just takes over when you are in a commit and push cycle. You have been building out somethings and making tests, maybe using some snippets you probably don’t want to be shared. Then, in a moment of clarity, you realize that you have been pushing these changes up to github!
Hopefully, you caught this in time and you just need to go back and remove those last few commits from github. This is a pretty straight forward task. Simply go into github and take a look at your last commits. Find the offending commit and copy the commit hash. Then it’s just a matter of running:
git push origin +HASH^:development
Let’s say we have the following in github:
We want to remove the commit with the hash 8a9554b. We would run:
git push origin +8a9554b^:development
This will remove the last commit from github.
The next step would be to remove this from your local repository. Because if we don’t do this, then the commit will be added again. And that would be very frustrating. To do this run
git reset HEAD^
This will remove the commit on the ‘top’. If you want to remove the last few run
git reset HEAD~X
Where X is how far you want to go back. For example, if you want to remove the last two, you would use git reset HEAD~2.
Lastly, we can re-push our local repository up to github to have everything back how we want.
Advanced Data Engineering Platform for Cleansing, Preprocessing and Analytics