在 Ubuntu 上搭建 git 服务器, git clone 有问题.

2017-10-08 17:19:39 +08:00
 SimleCp
我在 Ubuntu 上搭建了 git 服务器, git clone 的时候一直说没有权限或者文件夹不存在, 后来我尝试用 root 登录, ls -a, 显示的文件夹都是对的. 然后我用 git 登录, ls -a, 没有找到我自己创建的文件夹, 导致 git clone 一直找不到目标文件夹. 我换成 root 用户去 git clone, 没问题. 现在我该怎么办?
3055 次点击
所在节点    Linux
6 条回复
noe132
2017-10-08 18:27:21 +08:00
chown git:git /path/to/repo
NetCobra
2017-10-08 18:44:03 +08:00
权限问题,git 用户没有权限访问你创建的文件夹。
解决方案如 @noe132 的回复,不过最好加上-R 参数。
hawkflying
2017-10-08 20:55:50 +08:00
SimleCp
2017-10-09 09:27:34 +08:00
@noe132 我查看了权限, 如下, srv 显示 git, 但是用 ssh 登录 git 账户, ls -a 里面还是没有 srv 这个文件夹.
total 68
drwx------ 8 root root 4096 Oct 8 08:57 ./
drwxr-xr-x 23 root root 4096 Jul 26 00:47 ../
-rw------- 1 root root 2441 Oct 9 01:15 .bash_history
-rw-r--r-- 1 root root 3106 Oct 7 02:08 .bashrc
drwx------ 2 root root 4096 Jul 26 00:49 .cache/
drwx------ 2 root root 4096 Oct 7 01:53 .gnupg/
-rw------- 1 root root 244 Oct 7 03:00 .mysql_history
-rw-r--r-- 1 root root 221 Oct 7 02:10 .profile
drwxr-xr-x 3 git git 4096 Oct 8 08:39 srv/
SimleCp
2017-10-09 09:28:22 +08:00
@NetCobra 麻烦看下 4 楼. T - T
NetCobra
2017-10-15 09:50:27 +08:00
@SimleCp 怀疑你的 srv 文件夹是建立在别的用户的 home 目录里了。
在能显示 srv 目录的时候,用 pwd 看看你当前是在哪个目录里。
我猜按照你的配置应该是在 /home/git 目录里面才对。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/395962

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX