Posted Aug 6, 2008 2:21 UTC (Wed) by yarikoptic (subscriber, #36795)
Parent article: Git Magic
There is one imho important hint is given in the article, which is not unrolled well: "The
truly paranoid should always write down the latest 20-byte SHA1 hash of the HEAD somewhere
safe. It has to be safe, not private. For example, publishing it in a newspaper would work
well, because it's hard for an attacker to alter every copy of a newspaper."
Well -- if you are only up to using basic commands like fetch/merge/commit/... and not playing
with 'magic' rebase (or resets), then this hint is not so important to you. But git being
versatile could be somewhat fragile from the user's point of view -- you could easily lose
your HEAD while rebasing things around. Since git itself doesn't remove any known state
identified by sha-sum, it would remain in the repository even it is not within any of visible
branches (unless you do "git gc"). Thus you might loose your HEAD and get hours of your work
(or days) disappear magically (unless you pushed it somewhere or someone pulled from your
repository), but if you know SHA-sum you could easily reset your HEAD back to the desired
state.
Being totally paranoid (at times) I just tar-gzip whole repository before doing major rebases,
although now I can't even recall when I restored my repository back from the tarballs in the
event of the disaster ;)
Posted Aug 6, 2008 3:37 UTC (Wed) by newren (subscriber, #5160)
[Link]
Why not just use the reflog to recover? For example:
$ git reflog show HEAD
You can use a branch name, such as 'master', in the place of 'HEAD' too. That will show the
different sha1's that the branch (or HEAD) has stored over time with information about what
caused the change (a commit, a merge, a reset, a checkout, a rebase, etc.) You can also use
the named versions to obtain an old revision, e.g.
$ git reset --hard HEAD@{12}
Git Magic
Posted Aug 6, 2008 3:58 UTC (Wed) by yarikoptic (subscriber, #36795)
[Link]
learn new things every day! Now I will use it. not sure if for critical changes I would
abandon full-backup but now I would feel safer - Linus watched my back ;)