That’s exactly what you should do.
To explain a bit more:
git commit creates a commit on the current branch in your local copy of the repository (stored in the
.git/ directory). This lets you work with history locally, e.g. compare changes or go back to a specific version of your code. That protects you against mistakes, but not against your hard drive breaking. You can backup a local repository like any other files.
git push sends the commits on your current branch (or possibly another, depending on command line options) to a remote repository (e.g. on Github). If your laptop breaks and you get a new one, you can then clone the remote repository and you’ll have those commits that have been pushed to the remote repository.
One side note: You can use branches to work on things that aren’t ready for the main branch of your repository yet, or that you just want to try out. You can push all your branches separately.