git的钩权限问题 [英] git hook permission problem

查看:129
本文介绍了git的钩权限问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把我的混帐工作结构如下(这要归功于另一个问题混帐的建议:小项目工作

I've set my git working structure as follows (thanks to a recommendation in another question git : Small project work)

 /live/website
       |
       |
/path/to/staging (bare)
  |          |
  |          |
dev1        dev2

目前,这两个装置1和DEV 2,推动项目的 /路径/要/分期回购。我在/路径钩/到/分期,自动触发 git的拉从我的/生活/网站。这样一来,我所拥有的文件存在的工作副本。

Currently, both dev1 and dev2, push the projects to the /path/to/staging repo. I have a hook in /path/to/staging, that automatically triggers a git pull from my /live/website. This way, I have a working copy of files there.

还有 /路径/要/分期(裸)与份额= 0777初始化,所以我知道的一个事实份额是没有问题的。另外,我CHMODded所有文件到777,并设置棒位为好。

Also /path/to/staging (bare) was initialized with share=0777, so I know for a fact the share is not a problem. Also, I've CHMODded all files to 777 and set the stick bit as well.

我创建了/生活/网站回购为用户:根。不过,我已经创建了一个DEV1回购为用户:DEV1 。我可以在DEV1微调,但是当我试图推动从DEV1回购,这是我所面临的问题:

I've created the /live/website repo as user : root. However, I've created the repo in dev1 as user : dev1. I can make changes in dev1 fine, however when I try to push the repo from dev1, here's the problem I face:

error: Couldn't set refs/remotes/origin/master
From /path/to/staging
 ! 8b4fddc2 .. e2a0b21  master     -> origin/master  (unable to update local ref)
To path/to/staging
   8c5fddc2  .. e2a0b21 master -> master

基本上,我没有看到文件,成功地转移到/生活/网站。我觉得出现这个问题,因为我执行code作为用户:DEV1 。然而,当我浏览到 /生活/网站开通 e和做 git的拉手动为用户:根,它成功地拉由DEV1所做的更改,并改变工作文件

And basically, I don't see the files transfer successfully to /live/website. I think this problem arises since I'm executing the code as user : dev1. However, when I browse to /live/website and do a git pull manually as user : root, it does successfully pull the changes made by dev1 and changes the working file.

能有人建议,如果有一种方法来解决这个问题呢?由于它击败了自动挂钩的目的...

Can someone recommend if there is a way to work around this problem? Since it beats the purpose of the automatic hook ...

别的东西,我认为做的是钩,我想改变用户的:

Something else that I thought of doing was in the hook, I was thinking of changing the user:

su root
password

然而,在执行时,我不认为我在提示符下输入密码,因为我收到错误消息是:

However, when it executes, I don't think I'm entering the password at the prompt, since the error message I receive is :

hooks/post-receive: line 18: password: command not found


编辑,

另外,可以有人提出一个方法去从推回来?和下载文件的previous状态?

Also, can someone suggest a way to go back from a push? And get the previous state of files?

推荐答案

据我所知,你不能给苏在命令行中输入密码。但是你可以使用sudo,添加允许用户进入的/ etc / sudoers文件 无密码 ,所以你可以为 sudo的-u webside用户名'CD /生活/网站和放大器运行命令的;&安培;混帐取放&;&安培; git的结帐大师

AFAIK you can't give su a password on the command line. But you can use sudo, add the permitted user into /etc/sudoers with no password, so you can run your command as sudo -u webside-user-name 'cd /live/website && git fetch && git checkout master'.

这篇关于git的钩权限问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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