The basic setup for our Git workflow is a bare repository on a local network server with two developers pushing / pulling to it.
We would like to automatically checkout every branch that goes to another location on our local network server. To demonstrate:
Clicking "expand" branch copies to the "develop" subdirectory. Pressing the "leading" branch copies to the "master" subfolder.
The problem we are facing is to get an error message after that. Here is what we have at present:
#!/bin/bash while read oldrev newrev ref do branch=`echo $ref | cut -d/ -f3` if [ "master" == "$branch" ]; then GIT_WORK_TREE=/master git checkout -f $branch echo 'Changes pushed master.' fi if [ "develop" == "$branch" ]; then GIT_WORK_TREE=/develop git checkout -f $branch echo 'Changes pushed to develop.' fi done
Received error:
'remote: fatal: this operation should be performed in the remote: work tree: changes are pending. ''
As expected from this error, nothing has actually been verified.
I also tried post-receive this way, but the same problem:
#!/bin/bash while read oldrev newrev ref do branch=`echo $ref | cut -d/ -f3` if [ "master" == "$branch" ]; then git --work-tree=/master checkout -f $branch echo 'Changes pushed master.' fi if [ "develop" == "$branch" ]; then git --work-tree=/develop checkout -f $branch echo 'Changes pushed to develop.' fi done
Can someone explain what I'm doing wrong here (feel free to explain this as you would for a 3 year old :)). Thanks.
To make the answer clearer for future readers , Torek hit him on the head. I used --work-tree=/master to try to get to the folder named "master" inside the root of my bare repo (for example, next to the "branches", "hooks", etc.). As soon as I change this to --work-tree=./master (note the dot before the slash), everything works as I expected.
git git-post-receive
Ben train
source share