Git: Revert to the last working state at any given point

Have you already had this experience?

Two years after graduation, I remember it all too well.

The project is due tomorrow. It grew to an astounding amount of code.

You're just about to fix a glitch that you noticed. In the course, you make some changes. You run the program... Bang! An error pops up, and this time it is super-strange. You read it once, twice... seems unrelated to anything you've just done.

You want to revert recent changes. You remember how this place was a moment ago. Wait... If you change this back, you'll need to change that other place too, because it depends on the outcome from here.

The list goes on and on. You're lost in the current state, and too scared to even begin the process of reverting recent changes.

This goes on late into the night. You finally fix the problem, and the program is even better now.

It cost you a whole evening, and a great amount of stress.

Try it now

Install Git. If you are on Linux, try installing Git with your package manager.

On my system (Fedora), it is under dnf install.

On Ubuntu/Debian, do apt install git.

On Mac, try brew install git.

Create an empty directory with mkdir myproject.

Go to that directory: cd myproject.