4 ms·
That list is missing a level zero: "It already does, you just haven't found it yet." (Not applicable here, mind you.)
by phyzome 7y ago
That list is missing a level zero: "It already does, you just haven't found it yet." (Not applicable here, mind you.)
- Pxtl 7y agoYes, I recently discovered "git cherry" in exactly that kind of situation. In general I'm gradually sinking into "the emperor has no clothes" when it comes to git, at least on the subject of squashing vs painstakingly manipulating history vs accepting filthy history... But I also admit the amount of stuff you can do with git is so endless that I'm always surprised to find it has a good solution for a problem I never even considered tackling before it came up.
- jatone 7y agogit is really simple it only has like 6 atomic operations. thats what makes it so beautiful. a git rebase to reorder the commits and drop the uninteresting ones would produce the result wanted here. along with a few other approaches.
- Pxtl 7y agoI'm aware of the interactive rebase and the simple rebase, but the amount of stuff we throw at students and juniors, asking them to clean their history in such a hoary old ui seems like a lot to ask. Plus, I've become painfully aware of what happens when you encourage squashing and rebasing but developers don't carefully delete the source branches. The housekeeping of old branches is nightmarish since they're all ahead of the target, because rebasing means the commits aren't the commits. And it means allowing force-push on our git server.
- TheCraiggers 7y agogit rebase is akin to being a wizard but forbidden to use magic. I know it's there. I know it could solve a ton of my problems. But I can't use it because it would break everything from the feature-branch promotion model to my teammate's repos. It's basically useless to me, despite all the power it grants me.
- adrianN 7y agoThe trick is rebasing your stuff before you push it anywhere.
- dharmab 7y agoWe use rebase heavily and it makes our lives so much easier. The main rule is that we never rebase anything in the main repository- only in our forks. And everyone accepts that the forks are unstable.
- lmm 7y agoWhat do you actually get out of it though? Everyone talks about "clean history" but how much do you actually use that history? (except to bisect - and bisect works better without rebasing, IME) You're definitely missing out on being able to pull each other's branches - that's a huge help for avoiding conflicts ahead of time (if you know your colleague is halfway through a change in a given code area, start from their branch rather than master) or for unblocking development while a quickfix is making its way to master. I could believe that tradeoff could be worthwhile, but I've never found that rebasing offers any real advantages in practice.
- deleted 7y ago[deleted]
- phyzome 7y agoI use it all the time! I do really messy stuff locally, and then I rebase to organize it into commits that tell a story, which makes it easier for reviewers (and archaeologists, such as me in 5 months) to understand. Most common pattern: Commit 1 does a preliminary refactoring, commit 2 does the actual feature change. If you squash them together, the changes are harder to understand. But in the editing process, I often end up doing additional refactoring before I'm done with the feature work, so I use rebase -i to reorder and squash the changes appropriately. (I also run tests at both commits to make sure that my story is true, heh.) (This way, you can even do things like later revert the feature change without undoing the refactoring work.)
- _ZeD_ 7y ago"git" and "beautiful" should not be in the same sentence.