Pregunta

I have configured a git server, but when I'm trying to push the changes, always display:

fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

I created the keys and create a directory to save my project:

Remote server configuration

$ cd /opt/git
$ mkdir project.git
$ cd project.git
$ git --bare init

Local machine

$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@192.168.20.24:/opt/git/project.git
$ git push origin master

And here is when the error occurs.

fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

I'm verifying if the configuration is done, with the command in the local machinne

$ git remote -v
origin  git@192.168.212.139:/home/user/opt/git/project.git (fetch)
origin  git@192.168.212.139:/home/user/opt/git/project.git (push)

But, when I try push the commit, the message appears.

¿Fue útil?

Solución

Assuming you can ssh into the server, you created the repo in /opt/git/, and not in /home/user/opt/git/project.git

Try using any of the following url instead for the remote

user@192.168.212.139:/opt/git/project.git
ssh://user@192.168.212.139:/opt/git/project.git

where user is the username with whose access you created the project.git, and to which you ssh into on the server. You can update the remote in your local project's .git/config file.

You seem to be following chapter 4.4 of git-scm book on setting up the git server, I would recommend reading through 4.1 to understand the various protocols (https://, ssh;//, and git@).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top