r/programming • • Jun 19 '15

GitFlow considered harmful

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

244 comments sorted by

View all comments

46

u/[deleted] Jun 19 '15

OP should rebase before merging feature branches.... seriously...

Flow is

  1. Open branch

  2. Commit early often, push upstream to work with others

  3. Finish features, pass QA

  4. Rebase on mainline [delete upstream copy of feature branch], pass QA

  5. Merge --no-ff

That way your history is totally linear and all non-trivial commits are on branches that don't zig-zag.

7

u/tieluohan Jun 19 '15

I'll say the same thing, this gives you the best of both worlds. Every feature branch will be a nicely separated block, but the rebase before merge makes the history linear and readable.

13

u/[deleted] Jun 19 '15

The trick is to have the discipline to QA before/after the rebase.

Also it would help if people didn't do

 git push => error , arrg!!!
 git pull
 git push

How about

git pull --rebase

??

2

u/tieluohan Jun 19 '15

The trick is to have the discipline to QA before/after the rebase.

Yes. You can always fuck up a rebase, or a change in trunk can cause unintended consequences with your changes. Of course, not rebasing your changes does not reduce the amount of QA needed, as the head of master will end up identical after the merge in both cases. The same chances of fucking up apply to both rebasing and merging without rebasing.

With some luck the rebase on master once it works on your machine can end up being the only version needing QA, making it even a smaller hassle!

As for doing QA multiple times, while you can't automate code review, automating all the automatable tests to work on every branch push to the release repository ended up working surprisingly well for as, giving us the luxury of kicking off the TA systems with a git push releaserepository featurebranch.

4

u/[deleted] Jun 19 '15

That's why you QA after the rebase. Also, your reflog would have the old pre-rebase commit so you could revert (branch) that if you need to.

You QA before rebasing because there is no point fighting with conflicts/etc until you know your code actually works. You want the window of "rebase, qa, merge" to be as short as possible because effectively you have locked others out of merging to mainline.

1

u/eddiemoya Jun 19 '15

You don't need the reflog unless some time has passed. ORIG_HEAD will contain the state before the rebase.

Btw, you probably mean reset, not revert. You can't revert a rebase.

1

u/[deleted] Jun 19 '15

Just use fetch.

2

u/[deleted] Jun 19 '15

The point is if you pull because the upstream has moved you're making needless merge commits ... just rebase your crap on top of their crap.

fetch will grab objects but not merge them. It doesn't solve the original push error.

2

u/[deleted] Jun 20 '15

Fetch makes no merge commits. Just do

git fetch
git diff --stat origin/master
git rebase origin/master

2

u/[deleted] Jun 20 '15
 git pull --rebase

Would do that.

2

u/skinny85 Jun 19 '15

OP here. I agree this is a good solution, but I can't see a way to enforce it.

18

u/[deleted] Jun 19 '15

openly criticize developers who use git like cvs.

1

u/[deleted] Jun 19 '15

Become tech lead or work for a place that does. For FOSS projects, become or convince the maintainer.

1

u/eddiemoya Jun 19 '15 edited Jun 19 '15

Enforcement can be handled by automating the processes and move code along those steps. If your specifically wondering how you can enforce a rebase, you can automate the merging of the feature branch and have the script reject a branch isn't fast forward able, and rejects anything that produces a merge conflict.

1

u/DieFledermouse Jun 19 '15

your history is totally linear

If you do merges, maybe you can look at linear history with git log --first-parent or --left-only.

2

u/[deleted] Jun 19 '15

you want to see where features are merged though...

1

u/Kache Jun 19 '15

Could you elaborate what do you mean by "push upstream to work with others"?

If it means what I think it means, wouldn't rebasing leave "copies" of commits in the "past"?

→ More replies (4)