Branches are a way of keeping several different tracks of development within a single source repository. Puppet environments are a lot like Git branches. You can have the same code with slight variations between branches, just as you can have different modules for different environments. In this section, we'll show you how to use Git branches to define environments on the Puppet master.
In the previous section, we created a production directory that was based on the master branch; we'll remove that directory now:
puppet@puppet:/etc/puppet/environments$ mv production production.master
Modify the post-receive hook to accept a branch variable. The hook will use this variable to create a directory on the Puppet master, as follows:
#!/bin/sh read oldrev newrev refname branch=${refname#*\/*\/} git push puppetmaster $branch ssh [email protected] "if [ ! -d /etc/puppetlabs/code/environments/$branch ]; then git clone /etc/puppetlabs/code...