Kodokon kodokon.com

Backing up your work and keeping versions

Set up a real safety net: backups, history and your first steps with Git.

7 min · 3 questions

Open this lesson in Kodokon

Everyone has a story about lost work: the overwritten file, the USB stick left on the train, the change that broke everything with no way back. That is not bad luck, it is a lack of organization. There are three safety nets, and they complement each other: save often, copy elsewhere, and version.

For backups, remember the 3-2-1 rule: at least 3 copies of your data, on 2 different kinds of media, with 1 of them somewhere other than your home. An external drive plus an online service is plenty. Watch out for a very common confusion: a folder synced to the cloud is not a backup. If you delete a file by mistake, the deletion spreads to every copy within seconds.

Git is a time machine for your files. Three words are enough to get started. A repository is a project folder that Git watches. A commit is a snapshot of the whole project at a given moment, along with a message explaining the change. The history is the sequence of those snapshots, which you can browse and go back to at will. Git runs entirely on your own machine, and services like GitHub or GitLab keep a copy of it online.

BASH
cd my-project
git init
git add .
git commit -m "First version of the site"
Create a repository and record a first snapshot of the project.
BASH
git status
git log --oneline
git diff
git restore index.html
See the state, the history, the pending changes, and undo those of one file.

Knowledge check

Make sure you remember the key points of this lesson.

  1. What is a commit?
    • A snapshot of the project at a given moment, with a message
    • A copy of the project emailed to a colleague
    • A compressed archive in zip format
  2. Why does syncing to the cloud not replace a backup?
    • Because it always costs money
    • Because a deletion or a mistake immediately spreads to every copy
    • Because it does not work offline
  3. What should never go into a Git repository?
    • The source code of the project
    • A file containing passwords or access keys
    • A README file explaining the project