3 ms·
With syslog, everything in git is "fearless"
by johnea 2y ago
With syslog, everything in git is "fearless"
- Yasuraka 2y agoDid you mean reflog? Either way, even simpler, imho, than any log that one has to comb through after the fact is to create a named backup branch=$(git branch --show-current) && git switch -c backup-${branch} && git switch - Carry on as planned and if you bork it all, switch to the backup branch which retains the original commits and all, delete the borked one and have another go git switch backup-somebranch && git branch -D somebranch && git branch -m somebranch
- 0xCAP 2y agoI have a custom bash function named "backup_branch" that does exactly that, along with "restore_backup" and "delete_backups". It's made my life 10x simpler.
- Pfiffer 2y agoI do this as well but `git reset --hard backup-somebranch` and try again if I mess it up.
- keybored 2y agoYou don’t have to comb through the reflog for the pre-rebase branch state. Use `@{1}` from the reflog of the branch (not `HEAD`).[1] Note: First I thought that `ORIG_HEAD` was the thing. But that won’t work if you did `git reset` during the rebase. (`ORIG_HEAD` is probably “original head”, not “origin head” (like the remote) that I first thought…) [1] You just have to comb through documentation!
- sunshowers 2y agoAssuming this is the reflog, this is not true. Because the working copy doesn't get snapshotted, it is relatively easy to lose uncommitted data. I've spent much of my professional career working on source control and even I've lost uncommitted data a few times. Dropbox doesn't have a notion of uncommitted data. Why should source control?
- hinkley 2y agoI have to use reflog, rebase -i and frequent commits to cover the spectrum of edge cases I deal with weekly. No two of them accomplish the entire job.
- sunshowers 2y agoYou should try out Jujutsu :)
- hinkley 2y agoIt's on my list.
- IshKebab 2y agoLong rebases are not. That's the whole point.
- globular-toast 2y agoAs long as you commit everything, yes. The reflog is the safety rope of git. Everyone who isn't confident with the reflog should go and learn it right now. Pick your most important repo. Make sure everything is committed. Doing something stupid like `git reset --hard HEAD~100`. Look how fucked your work is. Do `git reset --hard HEAD@{1}`. Look at how nothing was lost.
- everybodyknows 2y ago> reflog should go and learn it Among its other virtues, reflog makes safe the highly empowering 'git-commit --amend'.
- globular-toast 2y agoYep, and even the more powerful fixup workflow where you can essentially amend commits other than HEAD. I do it via git-autofixup: https://github.com/torbiak/git-autofixup https://github.com/torbiak/git-autofixup