linux - Git,有权限问题推送

标签 linux git

所以我是 Git 和一般开发的新手。我是几台不同机器上的 Linux 和 Mac 用户,并且有几台带有 AWS 的云服务器,我在所有这些机器上从事小型 python 项目。

我将首先尝试解释我想要什么,希望我即将找到适合我的用例的最佳解决方案。我希望能够在我拥有的任何设备、家里的 Ubuntu 桌面、工作 Macbook、云服务器、工作中的 Ubuntu 桌面和个人 Macbook 上编写代码。显然,我正在使用不同的主机名和用户名,我是唯一一个使用我的代码的人。

我仔细阅读了 git 指南,它在某种程度上起作用了。我尝试在我的云服务器上设置我的存储库,我也将更改代码。我一直在尝试从我的 Macbook 上提交和推送,但是一整天都收到一串权限错误,我不得不回到 repo 和 chown -R 作为我的 ssh wheel 用户,因为那里的每个对象都得到了以 root 身份覆盖。

以下是我在尝试从我的 macbook 推送时看到的一些示例错误消息:

提交:

macbook:dev macbookuser$ git commit
# On branch master
# Your branch is ahead of 'origin/master' by 6 commits.
#
nothing to commit, working directory clean

然后是推送:

macbook:dev macbookuser$ git push
user1@myserver-aka-repo.com's password: 
Counting objects: 18, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (14/14), 1.62 KiB, done.
Total 14 (delta 7), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects

fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To user1@myserver-aka-repo.com:/home/myserver-aka-repo/dev/.git
! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'user1@myserver-aka-repo.com:/home/myserver-aka-repo/dev/.git'

最佳答案

如果 chown 和 umask 0002 没有在服务器上解决这个问题,请确保您推送到的 repo 已经以正确的模式共享。

 git config core.sharedRepository

有关此选项的更多信息,请参阅“Git Push Error: insufficient permission for adding an object to repository database”。

我通常将core.sharedRepository设置为umask,并将我的umask设置为0002

关于linux - Git,有权限问题推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13246377/

相关文章:

java - 调用 shutdown.sh 后 Tomcat 关闭速度很慢?

linux - 如何配置Yum从自托管存储库更新

c - rawsocket sendto() 一些数据包被丢弃并且在网络中看不到

git 忽略除一个扩展名和文件夹结构之外的所有文件

iphone - git commit 不会将文件添加到 xcodeproj

linux - 变量名后的 '-'(破折号)在这里做什么?

linux - 我无法在 ubuntu 上启动 ejabberd

Git子模块初始化异步

java - 项目构建错误: Non-resolvable parent POM cannot find repository

git - Windows 上的 VS Code - git push 导致权限被拒绝(公钥)