CentOS: Git: “fatal: could not read from the remot

2019-08-11 01:47发布

( I have already read through this, and several other posts, thoroughly git: fatal: Could not read from remote repository )

I'm using my own server as a git server. I set it up according to several guides. Everything is fine except any operation that read or writes to the remote git repository.

Problem:

When I try to do anything that interacts with the remote server that I have set up, I get:

fatal: Could not read from remote repository.

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

in windows shell. In Cygwin it just hangs.

Quick Background:

I'm using CentOS 7 as the server and Windows 10 as the client.

On the server:

  • I made a new user 'git'
  • mkdir /home/git/myproject.git
  • git init --bare
  • opened up necessary ports 9418, 22, & 443 using:

    "firewall-cmd --permanent --add-port=22/tcp" and

    "firewall-cmd --reload"

On the client:

  • created a folder, created a text file with some text, ran 'git init', 'git add .'
  • setup rsa keys according to several guides

What Works:

I can ssh into the server fine with windows shell, cygwin and puTTy. The folder /home/git/mproject.git exists. git has been working fine locally using either windows shell or Cygwin.

Attempted solutions:

I've tried:

chmod 600 pyproject.git
chmod 700 pyproject.git
chmod 777 pyproject.git
git remote add origin git@my-site.com:/home/git/myproject.git
git remote add origin git@my-site:/home/git/myproject.git
git remote add origin ssh://git@my-site.com/home/git/myproject.git
git remote add origin ssh://git@my-site.com/repo-<wbr< a="">>/home/git/myproject.git..git
git remote add origin ssh://git@my-site.com/repo-<wbr< a="">>/home/git/myproject.git
git remote add origin git@my-site.com:/home/git/myproject.git
git clone git@my-site.com:/home/git/myproject.git
git remote add origin https://git@my-site.com/home/git/myproject.git
git clone ssh://git@my-site.com/home/git/myproject.git
git clone ssh://git@my-site.com/myproject.git
git clone https://git@my-site.com:myproject.git
git clone ssh://git@my-site.com/home/git/myproject.git
git clone git@my-site.com/home/git/myproject.git
git clone git@my-site.com:/home/git/myproject.git
git clone git@my-site.com/myproject.git

I can log into the server with ssh git@my-site.com just fine. I can also navigate to the /home/git/myproject.git folder. The ports are open. What else could be wrong?

标签: linux git centos
1条回答
放我归山
2楼-- · 2019-08-11 02:33

So the problem seems to have been that the client and the server were using versions of git that were very different. The client was using 1.9 I believe, and the server was using 2.6. Not only that, the versions of git differed depending on the whether I was using windows terminal or Cygwin.

Now, after removing old versions and updating git, commands like:

git remote add origin git@mysite.com:/home/git/myproject.git
git push origin master

work correctly.

查看更多
登录 后发表回答