无法在使用post_update挂接时在裸仓库中设置GIT_WORK_TREE变量 [英] unable to set GIT_WORK_TREE variable in a bare repository when using post_update hook

查看:72
本文介绍了无法在使用post_update挂接时在裸仓库中设置GIT_WORK_TREE变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试将 http://danielmiessler.com/study/git/#网站来管理我的网站。我正在使用git gui在win7中



我已经到了指令的最后一步:git push网站



在推送到网站后,我能够确认裸目录〜/ website.git中的对象目录已更新。



我的钩子叫做'post_update',它有以下内容:

 #!/ bin / sh 
echo
echo****将数据推送到Live Server>>〜/ hi.txt
echo
export> 〜.file1.txt
GIT_WORK_TREE = / home / *** / public_html / b1a
导出>> 〜.file1.txt
git checkout -f

当我转到/ public_html / b1a时它是一个空目录。请注意,我已将hooks目录和b1a更改为777.

我可以确认post_update钩子正在触发,因为我将环境变量打印到file1.txt(正如你上面看到的)。在我看到的文件中:

  GIT_DIR =。 

但没有看到GIT_WORK_TREE。没有能力设置我卡住了。



感谢任何帮助,



Bill

解决方案

编辑:好,现在我看到您的问题。



这是您需要的脚本:

 #! / bin / sh 
echo
echo****将数据推送到Live Server>>〜/ hi.txt
echo
GIT_WORK_TREE = / home / * ** / public_html / b1a git checkout -f

我真的不知道为什么,也不知道如何工作,但确实如此。



我不知道为什么您要将 export 输出重定向到这些文件 - 你真的需要这个吗?



这个脚本只是检查存储库的当前 HEAD GIT_WORK_TREE 目录。而已。如果您需要其他任何内容,请发表评论。






我认为您不会导出 GIT_WORK_TREE 变量。



尝试更改这些行,以便真正导出该变量,而不仅仅是设置它:

 #!/ bin / sh 
echo
echo****将数据推送到Live Server>>〜/ hi.txt
echo
export GIT_WORK_TREE = / home / *** / public_html / b1a
导出> 〜/ .file1.txt
git checkout -f

第一个 export 设置 GIT_WORK_TREE 值并将其标记为导出,第二个将所有当前导出的变量输出到文件中。



我在Linux上运行这个程序,但我希望它在git-bash上也是一样的......


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

解决方案

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...

这篇关于无法在使用post_update挂接时在裸仓库中设置GIT_WORK_TREE变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆