Hacker News new | ask | show | jobs
by Espressosaurus 1043 days ago
I agree that if you're having to use the reflog frequently, you're using git wrong (not least of which because the reflog is not designed for readability and understanding the context where it came from).

But for the rest? If you're working in a repo with more than 5 people, rebase, cherry-pick, and squash are necessary to keep your sanity. Merge nodes are awful once you get beyond more than maybe 3 developers.

2 comments

Someone else pointed out that it's probably confusing that I didn't mention that I do religiously squash my branches before committing, so we still have multiple developers with a clean main branch and no merge commits.
I usually use reflog to answer the question "What was the name of the branch I was just working on again?"

What's supposed to be wrong with that?

That's perfectly reasonable IMO.

If you just need to checkout the last branch you can also `git checkout -`

git config --global alias.recent for-each-ref --count=20 --sort=-committerdate --format='%(committerdate:short): %(refname:short)' refs/heads/

use it like

    > git recent
    2023-08-07: jimkubicek/add-journal-table-creator
    2023-08-07: main
    2023-07-28: backup/git-squash-to-main
    2023-07-28: backup/cleanup