Commited Changes


I’m a new user of github and I try to understand or to know whether a commit saves my files even when my laptop would break down. It says commiting stores my files to the local repository, but this “cloud” is a bit hard to imagine for me. Can I call my last commit with a new laptop? If so, I would not wait too long with pushing my files at my project… Thanks a lot for helping.

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.

Thank you very much for explaining me carefully. Question well answered.

1 Like