使用 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创建单独的UNIX user,或者在使用git init创建存储库之前,我必须遵循任何特定步骤或 git 命令先创建用户

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

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

# ls
HEAD  branches  config  description  hooks  info  objects  refs

以下是我在Windowsgit bash client side为初始签入某些文件而执行的命令,-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'

出现这种情况是因为在git bash/gui client安装时遵循Windows Settings

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

存储库应该使用--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命令也会显示特定用户所属的所有组。

最新更新