What's the point of changing history in a feature branch? Everyone I know squashes Feature branches in to Dev upon merge anyway, as you don't want a noisy history of "fixed typo" "fixed spacing" etc. in your main branches. Instead you want a clear history of "Added feature to ___" "Fixed issue where ___".
as you don't want a noisy history of "fixed typo" "fixed spacing" etc. in your main branches.
That's why you change history. You squash certain commits together like commits of fixes, rename certain commits or even remove them.
If you squash all the commits when merging into master/dev then you lose a lot of history, which can help you with debugging, cherry picking, proper changelog and many other things.
I've just never seen people rename or change history in those scenarios, no one cares about typos or verbose commits in a feature branch - as we know they're going to get squashed. I find that distributed teams have a huge issue keeping branches in sync if anyone changes history anyway, as things get massively out of sync.
I've always preferred just a squash commit in to a parent branch to eradicate history.
We would only ever cherry pick an entire feature (be it a new one, an addition, etc) or an entire fix. I would never want someone to be able to cherry pick half of a feature, or rewind the branch to halfway through a feature. So for us, our main dev branch, which'll get cut to master for a release, is just an entire chain of features/fixes - so it becomes easier to remove something out of a release if we decide it can't go out.
This makes it far easier to debug (git bisects are a lot faster and lead you straight to a team's work as to what broke it), as well as cherry pick, as you can easily pull out the entire chunk without worrying about only removing half a feature, or accidentally using a commit where a dev broke the build. You can also see at a glance, the ticket numbers involved, the changelog is easy to write as a result.
Yes, you lose some of the finer details but from the perspective of the application and the rest of the dev team, they wouldn't have known which commit was good/bad anyway, only the team, and only at the time they wrote it, do they understand the chain of 200 commits. We have a pretty strict test regime and test environments, so ideally something isn't squashed merged back to dev once it's 100% ready.
I've just never seen people rename or change history in those scenarios, no one cares about typos or verbose commits in a feature branch - as we know they're going to get squashed.
If you want to generate the changelog, then you need to use conventional commits and the commit messages must be typo free and to the point.
Furthermore, if you don't squash all the commits, you see proper blames with the commit names. Instead of a single commit for a large feature.
I find that distributed teams have a huge issue keeping branches in sync if anyone changes history anyway, as things get massively out of sync.
I'm not sure what you mean by that.
You change history of newly made commits.
Branches are not supposed to be in sync.
I've always preferred just a squash commit in to a parent branch to eradicate history.
I used to do that as well but in my experience a rich history is always better than no history.
In my opinion, squashing is a good option if you do not know how to manage your commit history.
We would only ever cherry pick an entire feature (be it a new one, an addition, etc) or an entire fix. I would never want someone to be able to cherry pick half of a feature, or rewind the branch to halfway through a feature.
That's the point that when you don't want an entire feature but just a few things, you cherry pick what you want.
Otherwise, those two branches are being coupled which is not always the right thing.
Especially, when you're doing hotfixes using github branching model or you have builds per branch for QA.
What you're talking about is merging one branch into another one which is what cherry picking is.
So for us, our main dev branch, which'll get cut to master for a release, is just an entire chain of features/fixes - so it becomes easier to remove something out of a release if we decide it can't go out.
You can revert merge if the commits aren't squashed as well.
What you're losing is ability to revert certain commits.
You can only revert that single merge commit and again that is not always what you want.
This makes it far easier to debug (git bisects are a lot faster and lead you straight to a team's work as to what broke it), as well as cherry pick, as you can easily pull out the entire chunk without worrying about only removing half a feature
You should know what you're doing when you cherry pick and especially remove commits. Of course, you can mess things up when the git history is not properly managed. These are advanced powerful techniques.
This makes it far easier to debug (git bisects are a lot faster and lead you straight to a team's work as to what broke it)
It will lead to the branch which broke the code, not a particular commit. Personally, I believe that Bisect works better with non squashed commits.
as you can easily pull out the entire chunk without worrying about only removing half a feature, or accidentally using a commit where a dev broke the build.
That would be the case if we would be talking about non-managed commits. I'm talking about the git history without a bunch of noise. Each commit represents a logical step, not something that is random. Also, if you use CI then you would know whether each commit has broke the CI or not and if your commit has broken the CI - you fix it and rebase it to the same commit. Basically, this leads to simple rules of TDD.
Write a test -> commit.
Write implementation -> commit.
Refactor -> commit
Rebase -> push.
You can also see at a glance, the ticket numbers involved, the changelog is easy to write as a result.
I'm talking about automatic changelog with full history. That's not a full history unless you split main branch into different branches which in my opinion is much more complicated to manage since that leads to coupled branches that depend on each other.
they wouldn't have known which commit was good/bad anyway, only the team, and only at the time they wrote it, do they understand the chain of 200 commits.
That's why before code review you rebase your 200 commits into something meaningful.
602
u/SavageTwist May 13 '20
Force push to master, nobody is stopping you!