Git: Automatic Merges With Server Side Hooks (For The Win!)

Nicola Paolucci
Nicola Paolucci
Retour à la liste

Les workflows DVCS des entreprises se mettent en place et les modèles se renforcent. Git apporte une telle flexibilité aux équipes qu'au sein d'une seule entreprise, plusieurs équipes peuvent utiliser différentes approches pour partager le code et collaborer.

I speak from hard evidence as this is exactly what happens at Atlassian. The Bitbucket Server team works differently than the Confluence team which works differently from the Jira team. They all share a similar Agile process but have different approaches to branching, Continuous Integration and team organization.

Differences not withstanding, common patterns are emerging. A recurring paradigm in the industry is the use of a centralized repository with a master branch, several stable lines of development and follow a feature branch workflow where new features and bug fixes can be developed independently. This provides quick integration and allows teams to leverage the efficiency boost that comes with DVCS.

Full branching model

If you read this and ponder a bit you might ask: if a company is following the centralized repository workflow listed above, why would they still need forks?

Le forking est utile et vital, même au sein de l'entreprise. Il y a plusieurs raisons à cela. Avant de les énumérer, revenons un peu en arrière pour donner un peu de contexte et quelques définitions.


  1. What is a Fork?
  2. Les forks remportent le titre de meilleur process open source
  3. Avez-vous besoin de forks dans votre entreprise ?
  4. Protégez les composants de base, mais encouragez l'innovation et l'adoption
  5. Organisez la collaboration entre les services
  6. Reduce noise
  7. Streamline interaction with contractors
  8. Interactions des développeurs derrière le pare-feu
  9. Conclusions

What is a Fork?

In recent DVCS terminology a fork is a remote, server-side copy of a repository, distinct from the original. A clone is not a fork; a clone is a local copy of some remote repository. This differs slightly form the general definition of forks in software development but is the meaning that I will refer to in the course of this piece.

Les forks remportent le titre de meilleur process open source

If you have been living under a rock for the past several years let me reveal to you an indisputable fact: forks have won the Open Source process choice award. They foster participation by drastically lowering the barrier of entry and the friction of code collaboration.

Anybody can fork an open project and the original author does not incur in penalties or burdens because of it, the operation is transparent. He will potentially receive feedback or improvements in the form of pull requests but that's it.

Avez-vous besoin de forks dans votre entreprise ?

A fully distributed de-centralized approach is effective for loosely connected open source teams but what about enterprise teams all working in the same office with a central repository? Are forks useful in this setting?

Forks are surprisingly useful also behind the firewalls of the enterprise.

In abstract terms forks can be used within an organization to manage trust, track the maturity of codebases and facilitate cross team collaboration.

Concrete examples include:

  • Protégez les composants de base, mais encouragez l'innovation et l'adoption.
  • Organize Cross department collaboration.
  • Réduisez le bruit.
  • Streamline interaction with contractors.
  • Developer to Developer interactions behind the firewall.

Let's see in more details each one.

Protégez les composants de base, mais encouragez l'innovation et l'adoption

De nombreuses entreprises possèdent des composants de base qui sont réutilisés dans l'ensemble de la société. Ces éléments sont souvent soumis à des politiques plus strictes concernant les personnes autorisées à effectuer des changements, ils ont des garanties de stabilité et des process de révision plus lourds.

Les forks permettent de bien protéger le code autorisé, mais ils encouragent également l'adoption et l'innovation.

A non-sanctioned team or a lone developer with interest in the matter can fork the project and start contributing, without requiring supervision and without disrupting the core team's work. Collaboration still happens as usual with pull requests and feature branches.

En maintenant les expériences en dehors des dépôts principaux, on peut gérer et suivre efficacement la maturité des contributions. Les hacks instables restent isolés dans leurs propres forks ; les éléments stables peuvent être mergés dans les composants de base une fois révisés. Pourquoi les forks offrent-ils ces possibilités alors que les clones normaux ne le font pas ? Parce que les forks prennent en charge le bit de suivi : tout le monde peut cloner localement et travailler sur ses propres expériences, mais le fait de pusher ce code vers un fork côté serveur permet de le suivre.

Atlassian has several core libraries shared between the various groups, like for example the Atlassian User Interface. Forks relieve the burden on the Core teams maintaining them. No spurious feature branches and a messy tree appear in their main repository anymore.

Organisez la collaboration entre les services

An alternative but similar scenario is also common: when there is no "core" or ruling team over a certain software component but several departments maintain their own modified versions of the same piece of infrastructure. Forks allow teams to have control and guarantees on their own variations. Collaboration between departments is still easy and transparent with pull requests and the awesome integration features of git.

Reduce noise

Plus les équipes s'agrandissent, plus le bruit des branches de fonctionnalité et des corrections de bug peut devenir trop important pour que les IU s'affichent correctement. L'historique de projet devient si désordonné qu'il est difficile de comprendre ce qu'il se passe et de savoir qu'est-ce que qui est mergé et à quel endroit. Ces outils peuvent alors perdre en efficacité.

Again forks allow sub-teams to collaborate in the open but keep the central repositories where integrations happen as clean as possible.

Streamline interaction with contractors

Another area where forks are valuable is in the interaction with third parties, contractors and freelances. By providing forks as the only access point for contractors to your repositories one can gain several benefits:

  • Maintenir votre dépôt principal propre et limité.
  • Intégrer le travail de tiers après une révision planifiée.
  • Retain the common git collaboration process.

Interactions des développeurs derrière le pare-feu

Let's not leave out one final and very important piece of the puzzle.

Developer's personal forks! A developer might be happy to hack, improve and enhance some piece of core infrastructure but he might not want to share his early work with the rest yet. Would you want him to push some mission critical proprietary code out in the open?

In other cases he might want to maintain a slightly different approach to a problem and keep the contribution locked up until he can prove that a certain design decision will reap benefits for his team. For this scenario personal forks are great.

Personal forks allow also for the kind of distributed, uncoordinated kind of interactions that have made DVCS extremely successful in Open Source communities.


Forks are not the answer to all code collaboration woes but offer an effective solution to several concerns. In this piece I presented some ideas that support the statement that forks inside the enterprise help manage trust, the maturity of code bases and facilitate cross team collaboration.

Let me conclude by shouting that Bitbucket Server's new release includes first class support for forks in addition to a whole lot of other features.

As usual ping me @durdn or the awesome team @AtlDevtools for more DVCS trend spotting and git content.

(Credits: Branching model image was originally forked from nvie's git-flow Keynote source)

Prêt à découvrir Git ?

Essayez ce tutoriel interactif.

Démarrez maintenant