1

I am trying to set git up with http://danielmiessler.com/study/git/#website to manage my site. I am working using the git gui in win7

I have gotten to the last step in the instructions: git push website

After pushing to the website, I was able to confirm that the object directory in bare directory ~/website.git is updated.

my hook is called 'post_update' it has the following contents

#!/bin/sh
echo
echo "**** Pushing data to Live Server.">>~/hi.txt
echo
export > ~.file1.txt
GIT_WORK_TREE=/home/***/public_html/b1a
export >> ~.file1.txt
git checkout -f

when I go to /public_html/b1a, it is an empty directory. Please note, I have changed the hooks directory and b1a to 777.

I can confirm that the post_update hook is firing, because I printing the environmental variables to file1.txt (as you can see above). In the file I see:

GIT_DIR="."

but GIT_WORK_TREE is not seen. without the ability to set this I am stuck.

I would appreciate any help,

Thanks in advance,

Bill

user1592380
  • 34,265
  • 92
  • 284
  • 515

1 Answers1

1

EDIT: ok, so now I see your problem.

This is the script you need:

#!/bin/sh
echo
echo "**** Pushing data to Live Server.">>~/hi.txt
echo
GIT_WORK_TREE=/home/***/public_html/b1a git checkout -f

I really don't know why nor how this works, but it does.

I don't know either why you were redirecting the export output to those files - do you really need that?

This script just check's out the current HEAD of the repository to the GIT_WORK_TREE directory. That's it. If you need anything else, please comment.


I think you're not exporting GIT_WORK_TREE variable.

Try changing those lines so you really export that variable instead of just setting it:

#!/bin/sh
echo
echo "**** Pushing data to Live Server.">>~/hi.txt
echo
export GIT_WORK_TREE=/home/***/public_html/b1a
export > ~/.file1.txt
git checkout -f

The first export sets GIT_WORK_TREE value's and marks it for export, the second one outputs all current exported variables to the file.

I'm running this on Linux, but I hope it's the same on git-bash...

mgarciaisaia
  • 14,521
  • 8
  • 57
  • 81
  • I have changed the file to look like yours. I am getting a remote: fatal: This operation must be run in a work tree error now. entire output is remote: remote: remote: fatal: This operation must be run in a work tree[K To ssh://****@****.net/home/***/website.git 5450e91..5192e4f master -> master updating local tracking ref 'refs/remotes/website/master' – user1592380 Nov 25 '12 at 20:17
  • I did just look in file1.txt and now I have: export GIT_WORK_TREE="/home/***/public_html/b1a" included. so that should be correct. but the export is still not happening. Please note that ~/website.git is a bare repository as specified in the article – user1592380 Nov 25 '12 at 20:27
  • Hi So, I finally figured this out. the hook had been trying to send to the b1a directory which is NOT a git directory ( neither bare nor normal ). that explains the error. - Regards, Bill – user1592380 Nov 26 '12 at 14:50