Coder Social home page Coder Social logo

juliogonzalez / git-master-develop-hooks Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2 KB

A set of local git hooks to enforce some guidelines when working with master/develop/feature branches rebase-only model

Shell 100.00%
git hooks rebase merge commit-hooks merge-hooks rebase-hooks commit

git-master-develop-hooks's Introduction

What is this?

Just a set of basic git hooks to prevent:

  • Merges
  • Commits to master (including cherry picking)
  • Rebases to master from branches other than develop.

Are you using it?

Yes, at my current job we have some git guidelines that can be confusing for some developers the first time they used them, or for people not familiar with git.

As we want to have a git log as clean as possible we have:

  • Two permanent branches: master and develop.
  • Feature branches. When complete, develop must be pulled, rebased to the feature branch for conflict analysis, and then the feature branch is rebased to develop.
  • Commits from develop to be rebased to master for a release.

How do I use the hooks?

Remember that local hooks are pushed along with your code.

This means that after a clone, your local repo will not have any kind of hooks.

Because of this, I created the setup-hooks script that must be executed for any new clone.

You can place it anywhere in your repository along with the .git-hooks folder, and when run will link the hooks from .git-hooks folder to <repo_root>/.git/hooks enabling them.

For your convenience, you can download the code as a Zip file to unzip it at your repo.

Are there any limitations?

First thing to keep in mind: These hooks are just a help to prevent common mistakes not a way to really enforce the guidelines.

This means that under some circumstances it will be still possible to merge, or to change master with commits from branches other than develop.

So remember this:

  • As said before, the local hooks are not pushed with the repo, so it is your developers' duty to install them using the setup-hooks script.
  • More important: you can still force fast-forward merges (--ff) that will not be detected by the hooks (I could not find a way to detect them and so far it seems it is not possible).
  • It is still possible to change the master branch from other branches at a remote by using git rebase --hard /
  • There could be other ways to evade the restrictions.

git-master-develop-hooks's People

Contributors

juliogonzalez avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.