4 ms·
Clean project history is overrated. If you work on a sizeable team with code review before merge workflow, the tip of the repository will be moving faster than
by barrkel 10y ago
Clean project history is overrated.
If you work on a sizeable team with code review before merge workflow, the tip of the repository will be moving faster than is pleasant or safe to rebase, and every so often, commits will exist in multiple different branches (in order to prevent blocking development pending a code review). You do not want to be rebasing commits such that they appear in multiple different branches with different hashes etc. It's a recipe for pain. And being blocked until code is reviewed and merged is hardly more productive.
Even working like this, git bisect works just as well to find a commit, and git log on an individual file works just as poorly as it always does (e.g. changes in merge conflict resolution are hidden by default).
Rebase if the commits only exist in your local repo. That's fine. But no more.
- sytse 10y agoI totally agree. I think your code should be clean and your history should be accurate. I think as developers we're very focussed on writing clean code and documentation. We should try to write clear commit messages that relay the intention. But we shouldn't worry about adding one more commit if it makes the code better. I wrote about it in detail in http://docs.gitlab.com/ce/workflow/gitlab_flow.html#squashing-commits-with-rebase http://docs.gitlab.com/ce/workflow/gitlab_flow.html#squashin... Of course rebasing is fine if you have not pushed your branch yet. BTW some teams do prefer a rebase workflow and we want to support them in GitLab too, showing a diff with the changes in an MR if the commit was overwritten
- sdegutis 10y ago> Clean project history is overrated. I go back and forth on this issue. On one hand, I like having commits that do one thing. Makes it easier to "read" a project's history, to revert things, to track down bug introductions. On the other hand, I like having a history of the mess of how I actually implemented something, because it's more accurate and more detailed, both of which help when I go all DETECTIVE-MODE: ACTIVATE. But on the other hand, the mess often includes such uselessly awful commit messages, and lots of terrible code that only existed for like 2 hours until I realized it was the wrong way to do it, and scrapped it. That's kind of a red earring. So I don't really have a firm opinion on it anymore. I just go with whatever I feel that day. That said, I'm a team of 1 and have been for about 4 years, so it doesn't matter too much in my case.
- gouggoug 10y ago> On the other hand, I like having a history of the mess of how I actually implemented something, because it's more accurate and more detailed, both of which help when I go all DETECTIVE-MODE: ACTIVATE. The "mess of how things were implemented" has 0 value for your fellow coworkers when it comes to understanding the code and tracking down bugs. Each and every commit should as much as possible be "atomic" with a clear message describing what was done (not the how) and why. It is in the commit message that the developper should go on explaining their implementation decisions. What I picture is a feature branch with multiple small commits leading to the full implementation of the feature. When comes the time to rebase and merge in master, the merge commit could include a detailed explanation of the implementation choices that were made.
- AlexCoventry 10y ago> I'm a team of 1 and have been for about 4 years What kind of work do you do?
- sdegutis 10y agoI work full time on a pretty standard low traffic online store web app written entirely in Clojure.
- AlexCoventry 10y agoAh! I remember you from #clojure. Been reading some Uncle Bob recently, turned on to him partly because I remember you speaking about him.
- StavrosK 10y agoWhy not rebase master into your branch, rebase your branch locally to clean it up, then merge it back into master? That way you get the best of both worlds.
- swalsh 10y agoI disagree, depending on your environment... it might be mission critical. In our continuous deploy environment, we're a revert first ask questions later shop. That means when we find something wrong we revert, and that happens a lot. Since we revert so often it is ESSENTIAL that history is clean. Sometimes your code is reverted before you have a chance to be consulted. It always sucks, but if it happens you want to be sure that your change isn't only partially reverted.
- yladiz 10y agoBut you can pretty easily revert a merge by providing the hash of the commit in master before the merge occurred. It can get tedious but it's better than risking multiple people rebasing the master branch. Another downside to doing rebase onto master is, if you don't squash, if you want to revert a rebase that's 50 commits in size, you have to go back to before the entire rebase and revert to there (or 100, 200+, that would be much more tedious and potentially error prone than reverting a merge). The only solution I can think of that doesn't have potential for rebase conflict is to make it one person's sole responsibility to rebase other branches onto master.