2

我在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,签入文件时遇到问题。需要为/var/repos/git我在其下创建 git 存储库的目录设置权限、用户、组。目前它是在root权限下完成的。在UNIX user使用git_git init

我观察--bareinitgit 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 Settings时被跟踪。git bash/gui client

或者它完全是repository权限问题或repository creation user问题UNIX

4

1 回答 1

2

存储库应该使用创建--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,已创建存储库,并且组git具有rwx用于维护修订的大部分文件夹。

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

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

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

于 2018-04-25T09:41:06.970 回答