101 ways to revert to your old code using Git

Git is a powerful tool to manage your project’s codebase. Chances you have to revert/ restore commits to get rid of bad codes, or some bugs that you can not find out; these are some cases that you may find yourself in most often:

Stage 1. Coded but haven’t git added yet:

Stage 2. Added ‘by accident’, but haven’t commited yet:

Stage 3. Commited, but ‘luckily’ haven’t pushed yet:

Stage 4. Commited, pushed, “saddo”!

Pushed = somebody pulled and got that code. You could not just come there and say ‘Hey, delete your code you just pulled‘. Instead, you just say ‘I did the wrong thing, get this instead!‘.

The thing to do now is to push another commit, the content is the revert of current commit:

Conclusion

As you can see, git is an important and a powerful tool to work with that fastens your development and makes life easier.

Leave a Reply