linux - 当我尝试推送到 Linux AWS 服务器上的裸存储库时,出现 'insufficient permission...' 错误

标签 linux git amazon-web-services push

更新(11/4): 只是为了测试一下这是否确实是我的 Linux 机器上的权限问题,

在 AWS Linux 裸存储库中,我执行了“sudo chmod -R 777”。并能够成功完成“git Push origin master”,我立即执行了“sudo chmod -R 770”。将权限更改回来。

当我尝试推送到我的 Linux AWS 服务器上的裸存储库时,出现“权限不足...”错误。

  $ git push origin master
    Counting objects: 4, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (4/4), 622 bytes | 0 bytes/s, done.
    Total 4 (delta 3), reused 0 (delta 0)
    remote: error: insufficient permission for adding an object to repository database objects
    remote: fatal: failed to write object
    error: unpack failed: unpack-objects abnormal exit
    To awsDev:/AWSbareRepo
     ! [remote rejected] master -> master (unpacker error)
    error: failed to push some refs to 'awsDev:/AWSbareRepo'

我可以 pull ,但不能推。我已经完成了“git ls-remote”,它可以正常返回远程存储库中的可用引用以及关联的提交 ID,因此连接不是问题。

我还在 .config 文件中将 core.sharedRepository 设置为 true:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
        sharedRepository = true
~
~
~

在我的 AWS linux 服务器上的裸存储库目录上,我执行“ls -la”并收到以下内容:

$ ls -la
total 40
drwxr-xr-x  7 root root 4096 Nov  4 04:56 .
dr-xr-xr-x 28 root root 4096 Oct 14 02:06 ..
drwxrwsr-x  2 root root 4096 Apr 16  2015 branches
-rwxrwSr--  1 root root   91 Nov  4 04:56 config
-rw-rwSr--  1 root root   73 Apr 16  2015 description
-rw-rwSr--  1 root root   23 Apr 16  2015 HEAD
drwxrwsr-x  2 root root 4096 Apr 16  2015 hooks
drwxrwsr-x  2 root root 4096 Apr 16  2015 info
drwxrwsr-x 12 root root 4096 Oct 14 03:21 objects
drwxrwsr-x  4 root root 4096 Apr 16  2015 refs

我已经通过 ssh 连接到我的服务器并尝试阅读 Git Push Error: insufficient..问题,但不确定我需要向哪个组授予许可?我是否需要在我的 AWS 服务器上添加一个与我的开发盒上的组匹配的新组?

附加信息: 如果我不清楚,我正在尝试将“git Push origin master”从本地开发盒发送到 AWS Linux 服务器。推送来 self 的本地 DEV 盒子,当我尝试推送时,我没有通过 SSH 连接到我的 AWS Linux 盒子。

不确定这是否有必要,但我的 AWS Linux 服务器有 IP 规则,这会阻止任何不是源 self 的 IP 地址的 SSH 连接。

最佳答案

(这个答案假设您使用 ssh+git 连接到存储库。)

当您通过 ssh 登录 AWS 时,尝试输入 id。这将为您提供您登录用户的用户 ID。当您发现这一点时,通过(在存储库内部)更改存储库的权限

chown -R user_id:user_id .

这会将存储库中所有文件的所有权更改为您登录的用户。 (:user_id 也会更改组所有权)

说明:您的存储库归 root 所有。除非您也以 root 身份登录,否则您将没有写入权限。

关于linux - 当我尝试推送到 Linux AWS 服务器上的裸存储库时,出现 'insufficient permission...' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33514186/

相关文章:

amazon-web-services - AWS IoT Mosquitto 证书错误

mysql - 如何在 AWS glue 中处理 '0000-00-00' - pyspark

linux - 在 Ubuntu 18.04 中安装旧版本的 gnu-make

c - 使用 xlib 将假按键事件发送到窗口

git - Xcode 4 混帐 —"This file does not exist at the requested revision"

Git checkout 分支不会改变工作目录

regex - 如何在 Linux 中只从 lscpu 中提取值?

linux - 无法从 atd 运行 X11(图形)程序

java - GitFlow 中的 Maven 版本控制

node.js - 如何从 Node Web 应用程序正确访问 AWS Api Gateway