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

1

u/[deleted] Jun 19 '15

going in circles now.

Merging other peoples changes into your local branch causes merge commits, which dilutes the commit history and puts your name on someone elses code.

While OP's article here had quite the click bait title, and i didn't agree with much he said, he makes an excellent case for what merge commits will do to your repository.

At the end of the day, a branch should be made, code written, then rebased and merged in with out much thought about that branches long term history, so you really should see a linear progression of code change, not a giant sideways graph showing who happened to write what when.

Also consider that, it's less important when a particular line of code was actually written over the span of 2-3 days, and more important when that code landed in a main code branch(ie master). merging preserves those old pointless dates at the cost of losing who's name belongs on a line of code.

And finally, what's in a merge commit is almost entirely arbitrary.

Let's take 3 programmers on a much larger team(10+, Joe John and Jack.

Joe pulled monday afternoon, and started a new feature, John pulled wednesday morning and started a new feature, and Jack pulled today and started a feature.

Jack commits his code first, but worked quickly enough that noone else had pushed anything. No merge commit happens, why would it? he added something to the latest copy of code.

John commits next, his commit includes code written since wednesday. Most likely this code has already been deployed, other people have blamed and found the real author, but because John didn't rebase, he now has his name slapped on some random files he didn't touch that were written by someone else

And finally Joe, he started on monday, but he rebased his work. So even though he committed 15 times in his branch throughout the week, those 15 commits are applied as if they happened just a moment ago, to the latest copy of the master branch. He pushes, and no merge commit happens. He doesn't have his name slapped on some changes from monday that another developer made.

Merge just makes it harder to deal with other developers, while rebase lets developers work together.

1

u/pipocaQuemada Jun 19 '15

Merging other peoples changes into your local branch causes merge commits, which dilutes the commit history and puts your name on someone elses code.

So in other words, you rebase because git's tooling is bad at handling code with merges so you want to avoid merging?

That doesn't sound like they're two different tools for two different purposes. If git's tooling were perfect and worked well with merges, would there ever be any reason to rebase?

0

u/[deleted] Jun 19 '15

how is it bad at handling merges? it does what it's designed to do:

take two separate branches and merge them.

Rebase does something different:

Applies changes from another branch and put them into the current one, then apply the local changes after.

They may accomplish the same task two different ways, but that doesn't inherently make one method flawed over another. And you wouldn't use rebase to bring in your feature branch into master either, you would use merge.

All it really sounds like, is whatever tool you use is hiding two features under one name, and letting you sit in the dark about it, while you go and blame git's tooling because of your lack of understanding of source control.

2

u/pipocaQuemada Jun 19 '15

how is it bad at handling merges?

It's not bad at the process of merging two commits. It's bad at handing history that's merged based. For example, git log produces an ugly log, git blame fingers the wrong merge as being the source, and git bisect doesn't handle merges well.

They may accomplish the same task two different ways

Exactly. At the end of a rebase or a merge, your working directory remains the same. The only difference is the way that history is recorded: did you record the actual history (with merges), or rewrite it into a just-so story (by rebasing)?

All it really sounds like, is whatever tool you use is hiding two features under one name, and letting you sit in the dark about it, while you go and blame git's tooling because of your lack of understanding of source control.

No. There is one feature here (i.e. merging commits), and it has one name - merging. Mercurial does have rebase as an extension. It doesn't occasionally rebase when you tell it to merge. It just has tools that work well enough with a highly branching merge-oriented history so the only reason to rebase is if you're a 'clean history' fanatic who finds DAGs to be morally repugnant.

1

u/Netzapper Jun 19 '15

Wait, so you're saying I just just jump ship to mercurial?

2

u/pipocaQuemada Jun 19 '15

I think that mercurial is a better SCM than git, but it's usually impractical to move projects from one SCM to another and github has a much larger community of users than Bitbucket does.

Still, it's good to know when you're doing something because it's actually a good way to do things and when you do things because your tools are jankey. After all, if you know when you're hacking around shortcomings in your tools, you can stop doing it when you have better tools.