if you use something like Gerrit to manage your Git repositories (which I recommend
Fuck. That.
Gerrit is a pain to use. It takes the normal flow of Git and breaks it completely. It takes the feature Git made easy to use -- branches -- and completely ignores it. It turns branches with several commits into commits that keep absolutely no history ("Why would I describe something when there is only a single commit message.").
So far, no one managed to explain to me, in convincing terms, what Gerrit is trying to solve. The only thing I can see is "when I merge, it floods the target branch with commits", which isn't actually a problem if you do a "--squash". One "manager" here tried to explain that they switched to Gerrit to get rid of a project that had 1000s branches. Really? I don't think he realized they just changed the problem of dealing with 1000s branches to a problem of dealing with 1000s commits not merged. So it turned a tool that there is plenty documentation, there is a very well known flow into something that reduces Git into SVN.
You can't directly merge with Gerrit. You need to pick the base commit/branch (if it's "develop") and cherry pick your commit on top of it; you need a special hook around otherwise Gerrit won't work properly. Reverting changes creates a new "branch" (commit), even if you're still dealing with the same "subject".
Gerrit is even more harmful than GitFlow. You lose all the knowledge your team already has about the tool -- and general version control flow --, you lose all the history you had during development due having a single commit for everything in that "branch", and you have to train everybody to use a tool in a non-standard way in which all available documentation about it is invalid.
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.
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.
If you branch from master, make a bunch of commits, then see you're several commits behind master(others pushing their commits to master), when you go to merge back in, a merge commit is created. Instead if you rebase master, it is putting your commits aside, fast forwarding your branch to latest master, then re applying your commits one by one. Tucking your code, history, and commit messages all as they were, but neatly into the latest version of the history. You can then merge this into master which will "fast forward" the branch, rather than cause a merge commit, allowing others to see what you did, with out a merge commit to gunk up history.
You really should understand what rebase does before you criticize people for using it out of ignorance.
I've just never in my life said, "Man, the quality of this software would be so much higher if only there weren't so many merge commits all over the place."
I understand for some people that the aesthetics of rarely-used metadata is very important. I'm just providing a counterpoint: I don't care what my log looks like, so long as it 100% describes the history of the project. rebase appears to destroy history, so I don't like it.
rebase appears to destroy history, so I don't like it.
Pretty sure you don't understand what it does.
Also, this has nothing to do with quality of the software itself, or quality of the code base, but rather, quality of development efforts. When you want to get ahold of the guy responsible for changing a line of code, git blame is useful, until merge commits come into play, and your name is plastered over someone elses code because they were working at the same time as you on something unrelated to you.
I'd rather just have a clear and correct history, than have a bunch of nonsense that makes history more difficult to read and understand
What if your feature branch had a bunch of typo commits? Does your team need to know that you tried to expand a variable in single quotes? Is that relevant to the history of the feature?
Why should a single new feature be spread across 4 commits, and intermingled with another feature's 6 commits? Why not have 1 commit per feature, request, idea?
Features are deployed as an entire set, so this aligns with 1 feature per commit. This makes rollbacks easy per feature too.
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.
No, phabricator amends your new commit to the existing differential; differential still has copies of all commits made. arc land will squash your entire feature after it's been approved.
The only history lost in git is the history of how you completed the feature, which frankly no one cares about; people care about what changes went into master (IE got deployed) and the changes of the feature.
Historically, if you really need to see the mistakes or discussion of the feature, you can always get linked back to the differential which has the full history.
If you scroll down to Revision Update History, you can see there's two diffs attached to this differential. This is the unuseful history lost by git, but saved by phab.
arc land is also entirely optional. you can always simply rebase and merge your branch into master then push, at which point phabricator can close the differential the same way arc land does it.
Exactly! It's not the tool that will solve the problem, it's the process. But the problem in the process is being used as an excuse to use this tool.
(Sadly, this is one of those "I was like that when I got here". When I joined the team, one of the first things we got was a training in Gerrit. When I asked why use such tool, said manager pointed this scenario. I wholeheartedly agree that someone "messed up somewhere along the way", but Gerrit is nowhere the tool to solve that. It's a process problem and no tool will solve it.)
67
u/juliob Jun 19 '15 edited Jun 19 '15
Fuck. That.
Gerrit is a pain to use. It takes the normal flow of Git and breaks it completely. It takes the feature Git made easy to use -- branches -- and completely ignores it. It turns branches with several commits into commits that keep absolutely no history ("Why would I describe something when there is only a single commit message.").
So far, no one managed to explain to me, in convincing terms, what Gerrit is trying to solve. The only thing I can see is "when I merge, it floods the target branch with commits", which isn't actually a problem if you do a "--squash". One "manager" here tried to explain that they switched to Gerrit to get rid of a project that had 1000s branches. Really? I don't think he realized they just changed the problem of dealing with 1000s branches to a problem of dealing with 1000s commits not merged. So it turned a tool that there is plenty documentation, there is a very well known flow into something that reduces Git into SVN.
You can't directly merge with Gerrit. You need to pick the base commit/branch (if it's "develop") and cherry pick your commit on top of it; you need a special hook around otherwise Gerrit won't work properly. Reverting changes creates a new "branch" (commit), even if you're still dealing with the same "subject".
Gerrit is even more harmful than GitFlow. You lose all the knowledge your team already has about the tool -- and general version control flow --, you lose all the history you had during development due having a single commit for everything in that "branch", and you have to train everybody to use a tool in a non-standard way in which all available documentation about it is invalid.