development

UNIX 그룹에서 공유 할 기존 git 저장소를 구성하는 방법

big-blog 2020. 9. 11. 19:17
반응형

UNIX 그룹에서 공유 할 기존 git 저장소를 구성하는 방법


이 시점까지 나만 쓸 수있는 기존 git repo (맨손으로 하나)가 있습니다. foo의 모든 구성원이 푸시 할 수 있도록 일부 UNIX 사용자 그룹 인 foo에 공개하고 싶습니다. 다음을 사용하여 git repo를 쉽게 설정할 수 있다는 것을 알고 있습니다 .

git init --bare --shared=group repodir
chgrp -R foo repodir

하지만 기존 저장소 디렉토리에 대해 동등한 작업이 필요합니다 .


repodir그룹의 사용자를 위해 작업중 인 기존 저장소를 만들려면 다음을 시도하십시오 foo.

chgrp -R foo repodir                 # set the group
chmod -R g+rw repodir                # allow the group to read/write
chmod g+s `find repodir -type d`     # new files get group id of directory
git init --bare --shared=all repodir # sets some important variables in repodir/config ("core.sharedRepository=2" and "receive.denyNonFastforwards=true")

repo dir에서 다음 명령을 실행하십시오.

git config core.sharedRepository group
chgrp -R foo repodir
chmod -R g+w repodir

편집 : 잦은 혼동을 해결하기 위해 group실제 키워드이므로이를 그룹 이름으로 바꾸면 안됩니다.


@David Underhill@kixorz 답변을 병합 하여 나만의 (최종) 솔루션을 만들었습니다.

그것은을위한 베어 의 repos와 비 베어 의 repos. 그들 사이에는 약간의 차이가 있지만 이런 방식으로 더 명확합니다.

베어 저장소

cd <repo.git>/                            # Enter inside the git repo
git config core.sharedRepository group    # Update the git's config
chgrp -R <group-name> .                   # Change files and directories' group
chmod -R g+w .                            # Change permissions
chmod g-w objects/pack/*                  # Git pack files should be immutable
find -type d -exec chmod g+s {} +         # New files get directory's group id

어디:

  • <repo.git>일반적으로 서버에있는 베어 저장소 디렉토리입니다 (예 :) my_project.git/.
  • <group-name>git 사용자 (예 : users ) 의 그룹 이름입니다 .

비 베어 리포지토리

cd <project_dir>/                         # Enter inside the project directory
git config core.sharedRepository group    # Update the git's config
chgrp -R <group-name> .                   # Change files and directories' group
chmod -R g+w .                            # Change permissions
chmod g-w .git/objects/pack/*             # Git pack files should be immutable
find -type d -exec chmod g+s {} +         # New files get directory's group id

어디:

  • <project_dir>.git폴더가 포함 된 프로젝트 디렉토리 입니다.
  • <group-name>git 사용자 (예 : users ) 의 그룹 이름입니다 .

이것은 아마도 필요하지 않을 수도 있지만 denyNonFastForwards 옵션 git init --bare --shared도 설정 한다는 점을 지적 할 가치가 있습니다.

git config receive.denyNonFastForwards true

이 옵션의 의미는 다음과 같습니다.

receive.denyNonFastForwards

If you rebase commits that you’ve already pushed and then try to push again, or otherwise try to push a commit to a remote branch that doesn’t contain the commit that the remote branch currently points to, you’ll be denied. This is generally good policy; but in the case of the rebase, you may determine that you know what you’re doing and can force-update the remote branch with a -f flag to your push command.

(from http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration)


In addition to the above answers of allowing a group to read/write you also need to add the user to the group (say "foo").

sudo usermod -a -G [groupname] [username]

Note: you will have to first create user if it doesn't exist

참고URL : https://stackoverflow.com/questions/3242282/how-to-configure-an-existing-git-repo-to-be-shared-by-a-unix-group

반응형