3

I'm following git's doc to cretae a repository on a remote server on the local pc :

$ git clone --bare my_project my_project.git 

I've copied the repository on the server

$ scp -r my_project.git myuser@myip:/opt/git 

but if I try to clone

git clone myuser@myip:/opt/git/my_project.git 

I get

fatal: 'opt/git/my_project.git' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

I though that it was a permission problem ,but if I connect with ssh myuser@myip I have no problem to create files o do anything ,the folder belongs to myuser.

3
  • This syntax would appear to work for me (even though the scp instead of git push is a bit odd way to go about it). But if you look at your error message, not the missing leading /. For (some reason unclear to me) git is look for opt/git/my_project.git relative to home of myuser and not /opt/git/my_project.git where it is. In other words, I must be missing a bit. Version? Perhaps try to prefix myuser with ssh:// scheme in case something in the name was causing trouble? Commented Jun 19, 2018 at 9:18
  • Thank you but I already solved it Commented Jun 19, 2018 at 9:22
  • 3
    In that case, you may want to share your findings for sake of the future readers. Commented Jun 19, 2018 at 9:24

1 Answer 1

1

First, check that your origin is set by running

git remote -v 

This should show you all of the push / fetch remotes for the project.

If this returns with no output, skip to last code block.

Verify remote name / address

If this returns showing that you have remotes set, check that the name of the remote matches the remote you are using in your commands.

$git remote -v myOrigin ssh://[email protected]:1234/myRepo.git (fetch) myOrigin ssh://[email protected]:1234/myRepo.git (push) # this will fail because `origin` is not set $git push origin master # you need to use $git push myOrigin master 

If you want to rename the remote or change the remote's URL, you'll want to first remove the old remote, and then add the correct one.

Remove the old remote

$git remote remove myOrigin 

Add missing remote

You can then add in the proper remote using

$git remote add origin ssh://[email protected]:1234/myRepo.git # this will now work as expected $git push origin master 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.