我在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仓库?我在提交文件时遇到了问题。对于目录/var/repos/git,需要设置什么样的权限、用户和组来创建git仓库,在当前情况下它是在root权限下完成的。我需要为git专门创建一个UNIX用户,还是在使用git init创建存储库之前需要遵循特定的步骤或git命令来先创建用户?
我注意到init的--bare选项会在git存储库下创建一些基本结构。但当我用git clone命令克隆我的存储库时,发现它是空的。
由于我使用了--bare选项,我能看到以下文件夹结构被创建:
# ls
HEAD branches config description hooks info objects refs
以下是我在Windows的git bash客户端上针对一些文件(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客户端
时遵循了Windows设置
引起的。
还是完全是UNIX
中仓库
权限问题或仓库创建用户
问题。
sudo
时,你的问题就开始了。sudo
是一个系统工具,只应该用于修改系统配置。Git不是系统配置。使用Git(或任何其他通常用于开发的工具)与sudo
一起使用是没有必要的,而且会导致(大部分)问题。 - axiac--shared
必须和--bare init
一起使用。 - Dev Anand Sadasivamgit push
出现问题,chmod -R g+wX
也无法解决我们尝试用--bare init
创建的repository
文件夹。 - Dev Anand Sadasivam