r/programming • • Jun 19 '15

GitFlow considered harmful

http://endoflineblog.com/gitflow-considered-harmful
13 Upvotes

244 comments sorted by

View all comments

Show parent comments

2

u/Netzapper Jun 19 '15

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.

14

u/[deleted] Jun 19 '15

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.

8

u/[deleted] Jun 19 '15

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.

1

u/ForeverAlot Jun 19 '15

Or you can rebase and force-with-lease, which is really entirely safe in a controlled environment.

1

u/[deleted] Jun 19 '15

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.

1

u/ForeverAlot Jun 20 '15

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.

5

u/cpatrickr Jun 19 '15

You can't just revise history to make it "cleaner," you monster. You know who else would've loved "rebase -i"... THE NAZIS.

→ More replies (1)

3

u/Netzapper Jun 19 '15

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.

3

u/johndbritton Jun 19 '15

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."

2

u/Netzapper Jun 19 '15

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.

2

u/mflood Jun 19 '15

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.

1

u/Netzapper Jun 19 '15

The auditors read the git log. I've just never seen a developer use it for anything but bisecting a bug.

2

u/ForeverAlot Jun 19 '15

Your developers want to have that information while they're bisecting, too.

And your auditors hate messy logs. Even if they don't realise it, or just don't complain to you about it, they do.

I have lost countless hours doing my job with colleagues who believe as you that the log is write-once-read-never. That is the ideal but it certainly isn't the reality, and when reality trumps it sucks to have followed the ideal.

3

u/ForeverAlot Jun 19 '15

"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.

3

u/dv_ Jun 19 '15

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.

1

u/julesjacobs Jun 19 '15

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.

1

u/ForeverAlot Jun 19 '15

How do you propose to distinguish related commits that need to be display-squashed from related commits that are purposefully separate?

1

u/julesjacobs Jun 19 '15

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.

4

u/[deleted] Jun 19 '15

rebase solves the issue of merge commits.

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.

4

u/Netzapper Jun 19 '15

Yep, I understand what it does technically.

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.

4

u/[deleted] Jun 19 '15

Yep, I understand what it does technically.

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

1

u/Netzapper Jun 19 '15

Pretty sure you don't understand what it does.

Apparently not. Although I just re-read the documentation.

Is there an article on using rebase that isn't focused on aesthetics?

If I already have a code review process, a change request process, and requirements documents electronically signed by each dev as he completes the requirement (all of which is required of me by law)... what facilities does rebase provide me, other than give my guys another opportunity to fuck up the central repo?

If rebase doesn't provide features or utility, only fiddles the aesthetics, this is just another tabs-vs-spaces debate. You like it your way because you're used to it. I like it my way because it's what I'm used to.

2

u/[deleted] Jun 19 '15

Wow, i wonder who wrote this line of code, i'll just git blame it

Ohh, Netzapper wrote it, let me talk to him.

VS.

Ohh, I wonder who wrote this line of code, I'll just git blame it, then grep the log to verify it's not a merge commit, if it is, git show the commit, find the parent commits and see which one is to blame for this line of code, then contact Netzapper since he wrote it.

What couldn't be simpler?!

1

u/Netzapper Jun 19 '15

Oh! In my shop that goes like:

"Wow, I wonder who is responsible for this line of code?" I'll query the requirements database to see which engineer last signed off on this module. Oh, it's giveupitscrazy... well, regardless of whether or not he wrote the code, he owns that module and reviewed it, so he's who I'll call. If he signed off on somebody else's code, it's okay, because he must understand it, or he wouldn't have signed off on it.

→ More replies (4)
→ More replies (11)

3

u/theinternn Jun 19 '15

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.

→ More replies (1)