关于 git 使用 git 创建和访问存储库的问题

Issue on git repository creation and accessibility using git

我在 UNIX 机器上创建了存储库,

$sudo git --bare init /var/repos/git/repo00001

我还为个人 UNIX users

执行了以下命令
$ git config --global user.email "MyfullName@mindtree.com"
$ git config --global user.name "Anand Sadasivam"

我应该在哪个目录下创建 git repsitories,我在签入文件时遇到问题。应该为我在其下创建 git 存储库的目录 /var/repos/git 设置什么权限、用户、组。目前它是在 root 特权下完成的。在使用 git init[=36= 创建存储库之前,我是否需要专门为 git 创建单独的 UNIX user 或我必须遵循的任何特定步骤或 git 命令以先创建用户]

我观察到 --bareinit 创建了一些在 git repository 下的基本结构。但是当我这样做时 git clone 我的存储库是空的。

由于我使用过--bare,我可以看到创建的文件夹结构如下,

# ls
HEAD  branches  config  description  hooks  info  objects  refs

以下是我在 git bash client sideWindows 执行的用于初始签入某些文件的命令,- Readme.txt

$ git clone anand@xx.xx.xx.xxx:/var/repos/git/repo00001
Cloning into 'repo00001'...
anand@xx.xx.xx.xxx's password:
warning: You appear to have cloned an empty repository.

<<I had created Readme.txt file under the present directory>>

$ git add Readme.txt

$ git status
On branch master

$ git commit -a
[master (root-commit) 8201309] Initial commit
 Committer: Anand Sadasivam <MMyEmpID@mindtree.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 Readme.txt

$ git push origin master
anand@xx.xx.xx.xxx's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 240 bytes | 120.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
error: remote unpack failed: unable to create temporary object directory
To xx.xx.xx.xxx:/var/repos/git/repo00001
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'anand@xx.xx.xx.xxx:/var/repos/git/repo00001'

$ git show-ref
82013098f6801ea32bb620b612f779c8dade6d83 refs/heads/master

$ git push origin HEAD:master
anand@xx.xx.xx.xxx's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 240 bytes | 120.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
error: remote unpack failed: unable to create temporary object directory
To xx.xx.xx.xxx:/var/repos/git/repo00001
 ! [remote rejected] HEAD -> master (unpacker error)
error: failed to push some refs to 'anand@xx.xx.xx.xxx:/var/repos/git/repo00001'

出现这种情况是因为Windows Settingsgit bash/gui client安装时被跟踪

或者完全是repository权限问题或者UNIX

中的repository creation user问题

存储库应使用 --bare init --shared 创建,我的意思是 shared 选项应该是附加的,并且应该在 - 说 git 登录和 sudo 命令下完成不被使用。创建存储库后,它将对组用户具有 rw 访问权限。

git@xx-xx-xx-xxx~/repos/repo00001$ ls -l
total 32
-rw-rw-r--  1 git git   23 Apr 20 06:44 HEAD
drwxrwxr-x  2 git git 4096 Apr 20 06:44 branches
-rw-rw-r--  1 git git   66 Apr 20 06:44 config
-rw-rw-r--  1 git git   73 Apr 20 06:44 description
drwxrwxr-x  2 git git 4096 Apr 20 06:44 hooks
drwxrwxr-x  2 git git 4096 Apr 20 06:44 info
drwxrwxr-x 62 git git 4096 Apr 25 08:22 objects
drwxrwxr-x  4 git git 4096 Apr 20 06:44 refs

因此,我已将所有需要使用 git 存储库的用户添加到组 git,如您所见,git:git 已创建存储库和组 gitrwx 用于维护修订的大部分文件夹。

我已经添加并验证了用户是否被添加到组中,- git

anand@capsimt00001:~$ sudo usermod -a -G git anand
anand@capsimt00001:~$ groups
anand geckoo git

groups命令显示特定用户所属的所有组。