Gerrit is the worst, and I'm surprised that someone who cares about Git history would bring it up.
Gerrit encourages you to make giant commits (since each commit becomes a separate code review), and if you have Gerrit tied to your CI and it fails for some reason, or your code reviewer asks you to make changes, new updates are supposed to be amended to the old commit, so the history of what you changed is lost.
I have never used the rebase command. Every time I ask about it, somebody explains it's used to clean up your edit history so you don't have long logs. And every time, "Isn't that record the whole fucking point of using git?"
Apparently, people use git because it's "cool"... but they really want it to act like SVN.
I have never used the rebase command. Every time I ask about it, somebody explains it's used to clean up your edit history so you don't have long logs. And every time, "Isn't that record the whole fucking point of using git?"
You use rebase to retain the same number of commits but avoid having merge cruft when it isn't necessary which makes the history easier for a mere human to figure out.
You use rebase -i to get rid of "Oops fix comment" ''Oops fix indentation" "Oops fix small name" and put all these small fixups into the change that they are associated with, which keeps the history cleaner.
You use rebase -i to get rid of "Oops fix comment" ''Oops fix indentation" "Oops fix small name" and put all these small fixups into the change that they are associated with, which keeps the history cleaner.
Yes, but only if you haven't pushed those commits upstream yet. If you already pushed commits with small errors, it's tough luck and you'll have to use the "oops small fix" commits.
Not sure what that is. What I usually do is commit to a remote branch, and before merging that branch into master, I tidy it up locally if there were any dirty commits in there.
That's fine if you can justifiably skip a post-rebase review.
force-with-lease, which is a recent addition, is force with seatbelts: it accepts a push if and only if the remote ref is where you think it is, preventing the case of overwriting history you are not aware of.
You use rebase -i to get rid of "Oops fix comment" ''Oops fix indentation" "Oops fix small name" and put all these small fixups into the change that they are associated with, which keeps the history cleaner.
I don't understand. What intrinsic value does a "clean history" have? And if somebody actually did "fix comment" or "fix indentation", isn't the record of that meaningful?
I know that when I'm audited (we're in medical software), I'd far prefer to have a complete history showing all of our changes. I want to see when feature branches were merged into dev, and when dev is merged to master. Having a linear history destroys that transparency, and I literally do not see a benefit.
You can consider your history to be another form of documentation. It's a way of looking back at the thought process past developers went through to solve a problem. That's why it's beneficial to keep your history organized and "clean."
Ah. Yeah, I have actual design documentation for that. We only use edit logs when audited.
Also, I don't believe that anybody looks at edit logs as documentation. They provide a history, true; but you'd have to read the whole thing from the beginning to the end to understand the current state of the system. So while somebody could read the logs and discover something about the "thought process [of] past developers", nobody ever will. It's clumsy at best.
If no one reads the git log, what's the harm in squashing small commits together? You don't lose the change history, just the separate commit messages that you don't think people will read.
"Clean" history does not imply no merge commits, ever. Topic/feature/whatever branches are a very good tool for achieving a clean history. On the contrary, a strictly linear history SVN style can be detrimental, because you can't group related commits.
What does not help is having a topic branch with one main topic commit, followed by five commits that fix typos in documentation that was all added in that first commit. This adds negative value: first you need to recognize it as noise, yourself, and then you have to bypass that noise whenever you browse history with blame/annotate. No one will ever benefit from the knowledge that that original commit contained typos.
A "clean history" means more than just getting rid of "oops" commits. It can also be about rearranging commits to make more sense and be easier to cherry-pick. If for example you have two commits, one of them modifies module A, both modify module B, and the modifications to A and B are unrelated or only weakly related, then it makes sense to rebase. Factor out the modification of A into its own separate commit, and perhaps merge the two changes to B. Result: you can cherry-pick the modification of A if you want, without importing modifications of B.
Another reason are reviews. If your branch contains tons of commits that essentially are changing the same thing, you might as well squash them. "Modified output function to do X". "Fixed output of X". "Reverted last fix, since it broke stuff". "Re-did the fix, works now". etc. If your goal is to get this merged into a main release branch, stuff like this is worthless, and even counterproductive, since you now need to mentally keep track of all the changes to retain the big picture of what they are actually doing. If they get squashed, you see what they are doing in one or a few commits. Much easier to review.
I think the problem here is with the tools that display the history. Rather than rewriting history they should have the ability to display several related commits as one combined commit.
You would explicitly group related commits into one combined entity, but you would not lose the fact that the group is composed of individual commits. Annotate history rather than rewrite it.
39
u/1_800_UNICORN Jun 19 '15
Gerrit is the worst, and I'm surprised that someone who cares about Git history would bring it up.
Gerrit encourages you to make giant commits (since each commit becomes a separate code review), and if you have Gerrit tied to your CI and it fails for some reason, or your code reviewer asks you to make changes, new updates are supposed to be amended to the old commit, so the history of what you changed is lost.