Ya' row ze: Lets go!

You are here

Auto rebase of branches matching a pattern

In some cases auto rebasing of branches is really helpful. for example: If a team is running a build server such as Jenkins, and they want to have a standard environmental deployment system configuration for each application - but allow for each app to have the settings tweaked, this might be very helpful. In this scenario, we can follow git-flow very easily and in addition to creating feature branches, we also create "environment" branches. These "env/" branches are long lived branches that contain the latest and greatest configuration properties of the application/environment.

The risk to this is that as new properties are added to the overall scheme, the environments will fall behind in configuration unless someone (or some thing) goes through and updates/merges the configurations. This is where adding a "post-merge" git hook to the mix is helpful. With this method we can add a one-line script that will look at all the local branches, and rebase only the "env/" branches with master once a change has been merged into master. If there are conflicts the user who issued the merge will need to resolve them before being able to push.

git branch -a|grep env/|sed -E "s/[ *]+(env\/.*)/git rebase master \1/"|sh

Back to top