Quantcast
Viewing latest article 3
Browse Latest Browse All 10

Quick backup with git

There are probably many ways. But this one looks pretty simple and takes seconds.

git add . && git commit -m "backup-$(date +%Y%m%d-%H%M)" && git reset HEAD^

After this command, nothing is changed in working tree or in branch history. But reflog gets a reference to the current tree content, which could be extracted (git help reflog) if you suddenly realize that you’ve messed things up.

Con’s: depends on proper .gitignore to avoid garbage in repository; can’t be used if there is something valuable in the staging area; reflog has limited lifetime, decreased even more by large rebases


Viewing latest article 3
Browse Latest Browse All 10

Trending Articles