没有根文件夹的GIT post-receive checkout [英] GIT post-receive checkout without root folder
问题描述
我是git的新手,试图弄清楚如何通过为web根目录结账来更新每个网站的网站。
我搜索了stackoverflow,只发现了关于如何克隆的主题,这不是我想要的。
到目前为止,我已经设置了我的本地和远程回购以及post-receive挂钩:
#!/ bin / sh
GIT_WORK_TREE = / path / to / website / httpdocs git checkout -f
我的问题是项目根文件夹包含在结帐中...当我将内容推送到远程仓库时,我最终得到了类似于
/path/to/website/httpdocs/project_root/index.php
想要实现的是有
pre $ / $ c $ / $ / $ / b $ / $ c>
如何在签出时省略项目根文件夹?
如果:
- / path / to / website / httpdocs是一个git repo
- / path / to / project_root是一个git仓库(即有一个
.git
目录)
然后你可以在你的 post-receive
钩子中使用:
git - git-dir = / path / to / project_root / .git --work-tree = / path / to / website / httpdocs checkout -f
但是如果你推送到 project_root
,它就是一个 bare repo,在这种情况下,它的根目录应该被称为 /project_root.git
,并且 post-receive
钩子看起来像:
git --git-dir = / path / to / project_root.git --work-tree = / path / to / website / httpdocs checkout - f
无论如何, project_root
必须是git repo的根。
OP choppingblock 评论:
$ b
看来这个问题是由eclipse git插件(EGit)引起的,它会自动创建一个根文件夹ame of the project。
我现在通过从/ path / to / website更改
至webroot
的路径/ httpdocs/ path / to / website / httpdocs / project_root
。
I'm new to git, trying to figure out how to have a website updated with each push by doing a checkout to the web root. I have searched stackoverflow and only found topics about how to clone, which is not what i want. So far i have set up my local and remote repos, and a post-receive hook:
#!/bin/sh
GIT_WORK_TREE=/path/to/website/httpdocs git checkout -f
My problem is that the project root folder is included in the checkout... when i push contents to the remote repo, i end up with something like
/path/to/website/httpdocs/project_root/index.php
What i would like to achieve is having
/path/to/website/httpdocs/index.php
How can I omit the project root folder while checking out?
If:
- /path/to/website/httpdocs is a git repo
- /path/to/project_root is a git repo (i.e. there is a
.git
directory)
Then you can use in your post-receive
hook:
git --git-dir=/path/to/project_root/.git --work-tree=/path/to/website/httpdocs checkout -f
But if you are pushing to project_root
, it is rather a bare repo, in which case, its root directory should be called /project_root.git
, and the post-receive
hook would look like:
git --git-dir=/path/to/project_root.git --work-tree=/path/to/website/httpdocs checkout -f
In any case, project_root
must be the root of a git repo.
The OP choppingblock comments:
it seems that the problem is caused by the eclipse git plugin (EGit), which automatically creates a root folder with the name of the project.
I now worked around it by changing the path to thewebroot
from/path/to/website/httpdocs
to/path/to/website/httpdocs/project_root
.
这篇关于没有根文件夹的GIT post-receive checkout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!