development

GitHub로 푸시 오류-저장소 데이터베이스에 객체를 추가 할 수있는 권한이 없습니다

big-blog 2020. 7. 6. 06:58
반응형

GitHub로 푸시 오류-저장소 데이터베이스에 객체를 추가 할 수있는 권한이 없습니다


내 GitHub 리포지토리에 "git push"를 시도하는 동안 비정상적인 오류가 발생합니다.

계산 개체 : 8, 완료.
2 개의 스레드를 사용한 델타 압축.
압축 객체 : 100 % (4/4) 완료
객체 쓰기 : 100 % (5/5), 1.37 KiB, 완료
총 5 (델타 2), 재사용 된 0 (델타 0)
오류 : 저장소 데이터베이스에 개체를 추가 할 수있는 권한이 없습니다.

치명적 : 개체를 쓰지 못했습니다.
오류 : unpack-objects가 오류 코드 128과 함께 종료되었습니다
오류 : 포장 풀기 실패 : 포장 풀기 비정상 종료
git@github.com으로 : bixo / bixo.git
 ! [원격 거부 됨] master-> master (해당 패키지 없음 오류)
오류 : 일부 심판을 'git@github.com : bixo / bixo.git'으로 푸시하지 못했습니다.
  • GitHub에서 클린 클론 한 후 수정 된 파일을 편집 / 추가 / 커밋 / 푸시 할 수 있습니다.
  • 그런 다음 이것을 두 번 반복하면 위의 오류가 발생합니다.
  • 다른 GitHub 리포지토리로 잘 밀어 넣을 수 있습니다.
  • 내 파일 / 디렉토리 권한을 확인했는데 문제가없는 것 같습니다.
  • Mac OS X 10.5.8에서 git 1.6.2.3을 실행 중입니다.

위의 저장소는 이전 스택 오버플로 질문 ( SO 1904860 )의 재미의 원천 이므로 GitHub 리포지토리 가 손상 되었을 수 있습니다. 검색을 통해 찾은 유일한 유사한 문제는 github에서보고 된 압축 풀기 문제 였습니다 . 특히 GitHub를 사용 하지 않을 때 다른 사람이이 문제 를 겪은 적이 있습니까?


github 외부 에서이 오류가 표시되면 해결 방법이 있습니다.

http://mapopa.blogspot.com/2009/10/git-insufficient-permission-for-adding.html 에서 가져 왔습니다.

ssh me@myserver
cd repository/.git

sudo chmod -R g+ws *
sudo chgrp -R mygroup *

git config core.sharedRepository true

그런 다음 git 데몬은 .git / objects에 쓸 때 그룹 파일 권한을 사용해야합니다.


일반적으로이 문제는 Git 서버 파일 시스템에 대한 잘못된 사용자 및 그룹 권한으로 인해 발생합니다. 자식 저장소는 사용자와 그의 그룹이 소유해야합니다.

예:

사용자가 "git", 그룹 "gitgroup"및 Git 리포지토리의 위치는 git@mygitserverxyz.com : path / to / repo.git입니다.

그런 다음 :

sudo chown -R git : gitgroup 경로 /to/repo.git/

이것은 git 불충분 한 권한 오류를 수정했습니다.


sudo chmod 777 -R .git/objects

내가 시도했을 때 이런 일이 일어났다 git pull. 일부 분석에 따르면 누군가 과거에 루트로 커밋하여에 루트 소유권이있는 개체를 만들었습니다 .git/objects.

그래서 나는 달렸다

cd <repo>
la .git/objects/

그리고 그것은 root다음과 같은 일부 객체 (디렉토리)에 대한 소유권을 보여주었습니다 .

user@host:/repo> la .git/objects/
total 540
drwxr-xr-x 135 user user 4096 Jun 16 16:29 .
drwxr-xr-x   8 user user 4096 Jun 16 16:33 ..
drwxr-xr-x   2 user user 4096 Mar  1 17:28 01
drwxr-xr-x   2 user user 4096 Mar  1 17:28 02
drwxr-xr-x   2 user user 4096 Jun 16 16:27 03
drwxr-xr-x   2 user user 4096 Mar  3 13:22 04
drwxr-xr-x   2 root root 4096 Jun 16 16:29 05
drwxr-xr-x   2 user user 4096 Jun 16 16:28 07
drwxr-xr-x   2 root root 4096 Jun 16 16:29 08

그런 다음 나는 달렸다

sudo chown -R user:user .git/objects/

그리고 그것은 효과가 있었다!

I was replacing user with my real user, of course.


Nothing of the above worked for me. A couple of hours later I found the reason for the problem: I used a repo url of the type

ssh://git@example.com/~git/repo.git

Unfortunately I stored a putty session with the name example.com which was configured to login as user myOtherUser.

So, while I thought git connects to the host example.com with the User 'git', Git/TortoiseGit has connected to the putty session example.com which uses the User myOtherUser. This leads to the exact same ..insufficient permission.. error (cause both users are in different groups).

Solution: Rename the putty session example.com to myOtherUse@example.com


chmod should be chown, so the correct line is:

sudo chown -R gituser:gituser objects

Oddly enough, I had this issue on one clone of the repo I had, but not another I had. Aside from re-cloning the repo (which a coworker did to successfully get around this issue), I managed to do a "git reset" to the commit I had before the failures started. Then I re-committed the changes, and I was able to push successfully after that. So despite all the indications there was a problem on the server, in this case it apparently was indicative of some oddity in the local repo.


I was getting this error because every time a user push some content, the group of the file changed to the user. And then if some other user tried to push into the repository, it caused permission error and the push was rejected. So one need to ask your sysadmin to change the settings of the repository so that group of any file in the repository is not changed for any push by any user.

To avoid such problem, please ensure that when you initialize your git repository, use the command "git init --shared=group".


If you still get this error later after setting the permissions you may need to modify your creation mask. We found our new commits (folders under objects) were still being created with no group write permission, hence only the person who committed them could push into the repository.

We fixed this by setting the umask of the SSH users to 002 with an appropriate group shared by all users.

e.g.

umask 002

where the middle 0 is allowing group write by default.


After you add some stuff... commit them and after all finished push it! BANG!! Start all problems... As you should notice there are some differences in the way both new and existent projects were defined. If some other person tries to add/commit/push same files, or content (git keep both as same objects), we will face the following error:

$ git push
Counting objects: 31, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (21/21), 2.07 KiB | 0 bytes/s, done.
Total 21 (delta 12), reused 0 (delta 0)
remote: error: insufficient permission for adding an object to repository database ./objects  remote: fatal: failed to write object

To solve this problem you have to have something in mind operational system's permissions system as you are restricted by it in this case. Tu understand better the problem, go ahead and check your git object's folder (.git/objects). You will probably see something like that:

<your user_name>@<the machine name> objects]$ ls -la
total 200
drwxr-xr-x 25 <your user_name> <group_name> 2048 Feb 10 09:28 .
drwxr-xr-x  3 <his user_name> <group_name> 1024 Feb  3 15:06 ..
drwxr-xr-x  2 <his user_name> <group_name> 1024 Jan 31 13:39 02
drwxr-xr-x  2 <his user_name> <group_name> 1024 Feb  3 13:24 08

*Note that those file's permissions were granted only for your users, no one will never can changed it... *

Level       u   g   o
Permission rwx r-x ---
Binary     111 101 000
Octal       7   5   0

SOLVING THE PROBLEM

If you have super user permission, you can go forward and change all permissions by yourself using the step two, in any-other case you will need to ask all users with objects created with their users, use the following command to know who they are:

$ ls -la | awk '{print $3}' | sort -u 
<your user_name>
<his user_name>

Now you and all file's owner users will have to change those files permission, doing:

$ chmod -R 774 .

After that you will need to add a new property that is equivalent to --shared=group done for the new repository, according to the documentation, this make the repository group-writable, do it executing:

$ git config core.sharedRepository group

https://coderwall.com/p/8b3ksg


Try to do following:

Go to your Server

    cd rep.git
    chmod -R g+ws *
    chgrp -R git *
    git config core.sharedRepository true

Then go to your working copy(local repository) and repack it by git repack master

Works perfectly to me.


you can using this

sudo chown -R $USER:$USER "$(git rev-parse --show-toplevel)/.git"

sudo su root

chown -R user:group dir

The dir is your git repo.

Then do:

git pull origin master

You'll see changes about commits by others.


 user@M063:/var/www/html/app/.git/objects$ sudo chmod 777 -R .git/objects
 user@M063:/var/www/html/app/.git/objects$ sudo chown -R user:user .git/objects/

OK - turns out it was a permissions problem on GitHub that happened during the fork of emi/bixo to bixo/bixo. Once Tekkub fixed these, it started working again.


Since the error deals with permissions on the object folder, I did a chown directly on the objects folder and it worked for me.


This works:

sudo chmod -R gituser.gituser objects

I guess many like me ends up in forums like this when the git problem as described above occoures. However, there are so many causes that may lead to the problem that I just wanna share what caused my troubles for others to learn as I already learned from above.

I have my repos on a Linux NAS from sitecom (Never buy NAS from Sitecom, pleeaaase). I have a repo here that is cloned on many computers but which I suddenly was denied pushing to. Recently I installed a plugin so that my NAS could stand as a squeezebox server.

This server scans for media to share. What I did not know was that, possible because of a bug, the server changes the user and group setting to squeeze:user for all files it looks into. And that is ALL files. Thus altering the rights I had to push.

Server is gone and proper rights settings are re-established and everything works perfectly.

I used

chmod -R g+ws *
chown -R <myuser>:<mygroup> *

Where myuser and mygroup off-course must be replaced with proper settings for your system. try git:git or gituser:gituser or something else you might like.,


Check the repository: $ git remote -v

origin  ssh://git@example.com:2283/srv/git/repo.git (fetch)
origin  ssh://git@example.com:2283/srv/git/repo.git (push)

Note that there is a 'git@' substring here, it instructs git to authenticate as username 'git' on the remote server. If you omit this line, git will authenticate under different username, hence this error will occur.


In my case there were no unified authentication (e. g. within the domain + AD-like service) between my machine and git virtual server. Therefore git users and group are local for the virtual server. In my case my remote user (which I use to login into remote server) was just not added into remote git group.

ssh root@<remote_git_server>
usermod -G <remote_git_group> <your_remote_user>

After that check the permissions like it's described in the posts above...


Have you try sudo git push -u origin --all? Sometimes it's the only thing you need to avoid this problem. It asks you for the admin system password - the one you can make login to your machine -, and that's what you need to push - or commit, if it is the case.

참고URL : https://stackoverflow.com/questions/1918524/error-pushing-to-github-insufficient-permission-for-adding-an-object-to-reposi

반응형