Ask HN: How to Teach Git Rebase
One of the projects I work on has a Git Rebase workflow. Developers looking to get their changes into the main branch:
1. Do a rebase to get their branch in-sync with main, 2. Squash their branch's commits, 3. Make a push/force push to their branch, and 4. Create a pull request.
Which is lovely, but the process has a gnarly learning curve for our junior devs.
Is anyone familiar with documentation or tooling that does a good job of streamlining this sort of workflow?
13 comments
[ 5.0 ms ] story [ 166 ms ] threadhttps://gitimmersion.com/lab_31.html is likely where you would want to explore. hths!
N.B. This doesn't do squash!
That being said, the workflow for this project is unlikely to change. And, to be fair, the workflow has its benefits. The project history is very clean, PR code reviews are straightforward, etc.
Rebase workflows are so much additional work and the benefits don't actually seem worth that extra work. You can use the tools already available to get most of the same "benefits" and there's a lot less likelihood of needing to do a reflog search or deep dive into squashed commmits with no merge hints left of where a hidden three way merge took the wrong path or a need to manually manage some developer's rerere cache.
I'm biased, of course, by hitting so many of these worst case scenarios and being "the only expert" to get people out of them that I just generally don't trust any workflow that involves junior developers doing lots of unsupervised squashes and rebases. I like merge commits. I like having DAG traversal options when I need them (to fix some junior developer's accidentally bad merge; to archeology my way to deeper context around bugs). Those seem like much better "benefits" than "the project history is clean".
I can't recommend highly enough Learn Git Branching[1], an interactive demo for understanding rebases and cherry-picks.
Then try it a couple of tricky times, and you're settled.
[1]: https://learngitbranching.js.org/