Bourne-Again shell script, ASCII text executable
        
            1
            #!/bin/bash 
        
            2
            while read oldrev newrev refname 
        
            4
            do 
        
            5
                # Check if the refname starts with "refs/heads/" 
        
            6
                if [[ $refname == refs/heads/* ]]; then 
        
            7
                    # Extract the branch name from refname 
        
            8
                    branchname="${refname#refs/heads/}" 
        
            9
                    # Change to the repository's working tree 
        
            11
                    cd /path/to/your/repo/working/tree 
        
            12
                    # Update the working tree for the branch 
        
            14
                    git checkout -f "$branchname" 
        
            15
                fi 
        
            16
            done 
        
            17