git pull hook(更新后)没有任何反应 [英] Nothing happens on git pull hook (post-update)

查看:494
本文介绍了git pull hook(更新后)没有任何反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在实时服务器上执行git pull时,我以root用户身份登录,因此所有修改过的文件或新文件的用户和组均设置为root:root.

when I do a git pull on live server I'm logged in as root and so all modified or new files user and group are set to root:root.

我已经在我的post-update挂钩文件中尝试过此设置:

I've tried this set up in my post-update hook file:

OWNER="example:example"
REPO_PATH="/home/example/public_html"

cd $REPO_PATH || exit
unset GIT_DIR
FILES="$(git diff-tree -r --name-only --no-commit-id)"
git merge FETCH_HEAD

for file in $FILES
    do 
    chown $OWNER $file
done

exec git update-server-info

当我运行git pull时,它什么也没做.

When I run a git pull it just doesn't do anything.

推荐答案

运行git pull不会调用更新后挂钩:git pullgit fetch,后跟git rebasegit merge,更多或更少,并且合并实际上是合并时,rebase有效地以git checkout结尾. (对于所谓的 fast-forward 合并,git merge在内部进行的操作类似于git checkout,但也会更新当前的分支名称.)因此,这两个钩子更适合用于这种工作.

Running git pull does not invoke the post-update hook: git pull is git fetch followed by either git rebase or git merge, more or less, and rebase effectively ends with a git checkout while merge is, well, merge. (For so-called fast-forward merges, git merge does something much more like git checkout internally, but also updates the current branch name.) Thus, these two hooks are much more appropriate candidates for this kind of work.

Git包含一个contrib/hooks/setgitperms.perl示例脚本应该在post-checkoutpost-merge挂钩中使用.

Git includes a contrib/hooks/setgitperms.perl example script that's meant to be used in post-checkout and post-merge hooks.

(还值得一提的是,在实时服务器上运行git pull不一定是一种好的部署策略.Git本身不是部署系统,即按即用部署或按需部署都不适合自己它们可用于有限的子集,但通常,请考虑构建或使用实际的部署系统.)

(It's also worth mentioning that running git pull on a live server is not necessarily a good deployment strategy. Git itself is not a deployment system, and neither push-to-deploy nor pull-to-deploy are adequate by themselves for many real-world setups. They can work for limited subsets, but in general, consider building or using a real deployment system.)

这篇关于git pull hook(更新后)没有任何反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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