Git使用笔记解决[cloned an empty repository,,,][have the correct access rights,,,]
2020-06-13 14:38:42
浏览次数:113

在仓库中,git pull报错,

kex_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Git新建仓库,git clone告警,

warning: You appear to have cloned an empty repository.

解决以上问题,在git地址正确的前提下,需要注意:

  1. 权限
  2. 不是空仓库。

下文分别记录处理过程

  • 权限

搭建git服务器,参考CentOS7搭建Git服务器简易笔记

服务器端,repo文件夹需要git用户有权限访问

[root@yix]# mkdir yix_project.git
[root@yix repo]# chown yix_git:yix_git yix_project.git
[root@yix repo]# cd yix_project.git/
[root@yix repo]# git init --bare yix_project.git
Initialized empty Git repository in /data/repo/yix_project.git/
[root@yix repo]# chown -R yix_git:yix_git * -R
  • 空仓库

在客户端(以下是小编Windows平台使用 Git Bash的操作日志),

$ touch readme.md
$ vim readme.md

readme.md 内容任意,如:I have a dream.

$ git add *
$ git status

On branch master

No commits yet

Changes to be committed:
(use "git rm --cached <file>..." to unstage)

    new file:   readme.md
$ git commit -m "init"

[master (root-commit) 8178856] init
1 file changed, 1 insertion(+)
create mode 100644 readme.md

[master (root-commit) 8178856] init
1 file changed, 1 insertion(+)
create mode 100644 readme.md

$ git push

yix_git@yix's password:
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 206 bytes | 29.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To yix:/repo/yix_project.git

  • [new branch] master -> master
$ git pull

yix_git@yix's password:
Already up to date.

yix_git@www.yixzm.cn's password:
Already up to date.

版权声明


本文为博主原创文章,转载请附上博文链接!