News for hackers. Stuff that matters.
Re:GitButler: Fearless Rebasing by johnea on Wednesday October 23, 2024 @04:07PM (#41928836)
With syslog, everything in git is "fearless"
Re:GitButler: Fearless Rebasing by Yasuraka on Wednesday October 23, 2024 @04:44PM (#41929117)
Did 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
Re:GitButler: Fearless Rebasing by keybored on Wednesday October 23, 2024 @05:49PM (#41929561)
You 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!

Re:GitButler: Fearless Rebasing by 0xCAP on Wednesday October 23, 2024 @05:12PM (#41929299)
I 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.
Re:GitButler: Fearless Rebasing by Pfiffer on Wednesday October 23, 2024 @05:40PM (#41929508)
I do this as well but `git reset --hard backup-somebranch` and try again if I mess it up.
Re:GitButler: Fearless Rebasing by sunshowers on Wednesday October 23, 2024 @04:51PM (#41929164)
Assuming 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?

Re:GitButler: Fearless Rebasing by hinkley on Wednesday October 23, 2024 @06:02PM (#41929649)
I 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.
Re:GitButler: Fearless Rebasing by sunshowers on Wednesday October 23, 2024 @06:27PM (#41929835)
You should try out Jujutsu :)
Re:GitButler: Fearless Rebasing by hinkley on Wednesday October 23, 2024 @09:30PM (#41931029)
It's on my list.
Re:GitButler: Fearless Rebasing by IshKebab on Wednesday October 23, 2024 @05:10PM (#41929290)
Long rebases are not. That's the whole point.
Re:GitButler: Fearless Rebasing by globular-toast on Wednesday October 23, 2024 @05:44PM (#41929536)
As 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.

Re:GitButler: Fearless Rebasing by everybodyknows on Wednesday October 23, 2024 @09:51PM (#41931132)
> reflog should go and learn it

Among its other virtues, reflog makes safe the highly empowering 'git-commit --amend'.

Re:GitButler: Fearless Rebasing by globular-toast on Thursday October 24, 2024 @03:58AM (#41933168)
Yep, 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