News for hackers. Stuff that matters.
Re:Ask HN: Best Git workflow for small teams by qertoip on Sunday November 13, 2016 @05:07AM (#12942643)
Continuous integration AKA trunk based development is the workflow you want to have. Ensure you meet the prerequisites first though (reliable automated tests, solid code reviews, feature flags, etc).

To be precise, small feature branches are perfectly fine. They are meant to be reviewed and squashed into master ("trunk") in a few hours to a few days maximum.

Squashing instead of merging has a big advantage of being able to quickly revert the changes if things go awry despite all best practices in place.

PS Avoid gitflow and similar workflows as they introduce leaps and thus risk. As everything in software engineering, you want your workflow to be as incremental as possible.

Re:Ask HN: Best Git workflow for small teams by JimDabell on Sunday November 13, 2016 @06:54AM (#12942922)
> Squashing instead of merging has a big advantage of being able to quickly revert the changes if things go awry despite all best practices in place.

Merge with --no-ff. You can revert easily, but you don't throw away the feature branch history.

Re:Ask HN: Best Git workflow for small teams by tapan_k on Sunday November 13, 2016 @07:30AM (#12943023)
> but you don't throw away the feature branch history

Once a feature is merged, how is the history of a feature branch helpful?

Since I do not see/understand the benefits of retaining feature branch history, my preference is to squash commit and merge. Perhaps, this is a result of my habits that I carry from the ClearCase days, but would love to hear the downsides of this approach.

Re:Ask HN: Best Git workflow for small teams by JimDabell on Sunday November 13, 2016 @08:04AM (#12943133)
Well given that we're talking specifically about reverting the merge when something goes awry, firstly you want that history preserved so that you can re-start work on it, potentially without pulling in all of the changes in one go; and secondly so that you can determine the precise point at which the problem happened.

Consider the difference between:

* Well we need to revert this because it's causing problems, but now we've got one massive chunk of several day's work to pick through.

…vs:

* Well we need to revert this, but we can see that the problem was specifically commit xzy, so let's yank that, do it a different way, and merge the result.

Aside from that, it can be very useful to see the individual steps in implementing a feature for a variety of reasons. Given that a --no-ff merge achieves everything you are aiming for with the squash, why wouldn't you pick the more flexible approach?

Re:Ask HN: Best Git workflow for small teams by 32bitkid on Sunday November 13, 2016 @08:52AM (#12943305)
`git blame` and `git biscet`
Re:Ask HN: Best Git workflow for small teams by qertoip on Sunday November 13, 2016 @09:44AM (#12943496)
No, reverting a merge commit does not do what most developers think it does. Correctly reverting the merge is a know source of pain.
Re:Ask HN: Best Git workflow for small teams by fdgdasfadsf on Sunday November 13, 2016 @06:41AM (#12942889)
But a policy of squashing prevents two people from working on the same feature (you shouldn't squash what you've already pushed as this changes history).
Re:Ask HN: Best Git workflow for small teams by newjersey on Sunday November 13, 2016 @07:39AM (#12943058)
I'll go further: never* rewrite public history

*In most cases, I think we should consider invalidating secret keys instead of trying to delete it and hope nobody saw it.

Are there secret keys in your app that you can't invalidate without a lot of pain? Maybe it is time to change some things in your app.

Maybe if someone accidentally commits secret-evil-plan.txt you might want to rewrite history? I can't think of any other scenarios... I mean even if someone commits a secret key, you're probably better off revoking it and leaving the secret key there. Or should you delete that file anyway to prevent people trying to brute force your old revoked private key?

Re:Ask HN: Best Git workflow for small teams by JimDabell on Sunday November 13, 2016 @08:27AM (#12943200)
> *In most cases, I think we should consider invalidating secret keys instead of trying to delete it and hope nobody saw it.

Absolutely. AWS secret keys accidentally pushed to GitHub are abused within a few minutes. There's essentially no window where published keys remain safe.

Re:Ask HN: Best Git workflow for small teams by planteen on Sunday November 13, 2016 @12:35PM (#12944458)
That's for a public repo. I'd bet the vast majority of companies have private repos.
Re:Ask HN: Best Git workflow for small teams by eskimobloood on Sunday November 13, 2016 @08:26AM (#12943193)
Depends on what is "public" history. Is a branch where you working on alone public, or does it become public after merging in back to master. Squashing a branch before merging back depends a lot of the discipline of the commiter. So for a branch with commits like "add FeatureX", "arg forgot this edge case", "ups another fix", "finally it works" it makes a lot of sense to squash it. While for "add FeatureX", "fix some linter errors during development" it makes then to leave the history as it is.
Re:Ask HN: Best Git workflow for small teams by qertoip on Sunday November 13, 2016 @09:48AM (#12943519)
Code review is read only. Pair programming is at the same machine. Apart from that the features should be ultra-thin and delivered vertically end-to-end by a single programmer. That is the optimal model.
Re:Ask HN: Best Git workflow for small teams by fdgdasfadsf on Sunday November 13, 2016 @01:22PM (#12944732)
Optimal for what?