Cover photo by JESHOOTS.COM on Unsplash
I've been working with Git for a few years now and admittedly, a clean commit history wasn't always that...
For further actions, you may consider blocking this person and/or reporting abuse
Something I’d love to see edited into this is you can specify any commitish when interactively rebasing. When I’m squashing I almost always use
git rebase -i origin/master
. This way, you automatically get the right number of commits.Hi Christopher
That's a good point. But careful if your branch doesn't originate from master :-)
Fair point. I’ve been practicing trunk based development for quite some time now.
I declare the rebase point only if it has not been pushed yet. E.g. when I rebase only the last half of my local commits. Otherwise I keep it implicit.
GitHub has a feature squash-and-merge that works very well with team development. Devs create a feature branch for an issue and make as many commits as they want without any tidying. When the issue is finished you squash-and-merge it and it lands back onto the main integration branch as a single commit. The full history can still be seen on the feature branch. On the main integration branch the history shows when feature landed as an atomic commit which is always far more helpful than seeing the work in progress commits of the feature branch. Using this technique the history of a large project can be kept extremely clean with zero effort.
Not always useful as a feature branch may contain multiple units of work that could benefit from seperate commits. Really just depends on the scope of project and workflow.
sure. we prefer to break down work into small units that can be continuous integrated if we can. sometimes something large cannot. shipping something bigger in chunks hidden by a feature flag can reduce the integration risks. many teams work in sprints and try hard to make atomic tasks that can land as single commit where possible.
I really prefer to be able to trace each commit through history. That's pretty much the only time I practically need a history.
Sure, it's nice when it looks all tidy and orderly, but you lose information.
Can't have dirty garbage 😘
Couldn't help but mention
git reset - -hard ORIG_HEAD!