gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 04:06:19 24 4
gpt4 key购买 nike

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

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

此外,我还为个别 UNIX 用户 执行了以下命令,

$ git config --global user.email "MyfullName@mindtree.com"
$ git config --global user.name "Anand Sadasivam"

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

我观察到 --bareinitgit 存储库 下创建了一些基本结构。但是当我执行 git clone 时,我的存储库是空的。

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

# ls
HEAD branches config description hooks info objects refs

以下是我在 Windows 中的 git bash 客户端 执行的用于初始 checkin 某些文件的命令,- 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

或者在UNIX中完全是repository权限问题或者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 已创建存储库和组 git 对大多数要维护修订的文件夹都有 rwx

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

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

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

关于git - 关于使用 git 创建和访问 git 存储库的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49935303/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com