0

I'm trying to access a remote git repository using SSH but I'm getting a fatal error - is there a problem with my syntax?

I've created a git repo in the mysite folder on my server - so the repo is at /home/mysite/.git

git clone ssh://root@serverIP/mysite/.git
fatal: could not create work tree dir 'mysite'.: Permission denied

Can anyone see what is wrong with my syntax or is there another issue here?

3
  • It looks like you have no write permissions inside the directory you are working in.
    – Sgaduuw
    Aug 2, 2011 at 8:56
  • @Sgaduuw: No, this is not the problem. His syntax is wrong and git tries to create a repo somewhere.
    – Sven
    Aug 2, 2011 at 9:03
  • Yes the write permissions problem is because i didn't specify a local destination - that issue's gone, now on to new ones :)
    – harry83
    Aug 2, 2011 at 9:04

4 Answers 4

2

Try to use full path for target directory. For exampple:

git clone ssh://root@serverIP/mysite/.git /home/user_name/mysite

UPD:

When git clones repo it creates directory for it based on repo's name.

git clone [email protected]:username/repo.git

Git will create directory repo. But there is NO repo name in your case mysite/.git.

0

You must give ssh the whole path to your repo and the.git part is unnecessary, git can figure that one out by itself:

git clone ssh://root@serverIP/home/mysite 

Edited: When using the URL type ssh:// syntax, the colon I used earlier is not valid. There is another syntax (ssh style), which needs it:

 git clone root@serverIP:/home/mysite 

I usually prefer the second form.

1
  • thanks for the reply. I can connect ok now but when I try to clone to a local destination I get: warning: You appear to have cloned an empty repository. stdin: is not a tty
    – harry83
    Aug 2, 2011 at 9:20
0

A valid ssh URL should look like ssh://{user}@host.xz/path/to/repo.git, so you should be ok (if (mysite/.git is a valid path).

The issue should be on the local side: do you have write access to your current directory?


Once you have write access, you still have two messages:

  • stdin: is not a tty: that means something in your .bashrc or in the global .bashrc is waiting for an input: see ee for example:

There is a line (mesg y) inside the global bashrc file that will cause repeated messages when interacting with GIT (stdin: is not a tty)

That would not prevent a clone.

  • warning: You appear to have cloned an empty repository: that warning is independent from the previous message, and should be accurate if the repo you are cloning is, indeed, an empty one.
4
  • The write permissions issue is sorted, I wasn't specifying a local destination. I now get the error: warning: You appear to have cloned an empty repository. stdin: is not a tty
    – harry83
    Aug 2, 2011 at 9:06
  • @harry83: Have you added the /home part like I told you in my answer? SSH needs it, because it always start at the root directory.
    – Sven
    Aug 2, 2011 at 9:20
  • @SvenW - yes I have the same as you recommended, the full path containing /home/mysite
    – harry83
    Aug 2, 2011 at 9:28
  • @harry83: I have updated my answer.
    – VonC
    Aug 2, 2011 at 10:46
0

The problem for me was write access to the directory and I fixed it using "sudo". I had to create an alias in my bash profile that shorthanded the sudo command before the git command.

Below is the line I added to my .profile file and it works great. I no longer have the "fatal: could not create work tree dir..." message anymore.

alias sgit="sudo /usr/local/git/bin/git"

 

UPDATE

I spoke too soon. Doing this caused other issues with programs on my Mac to save files in the directory since the directory was owned by root. I had to change the root directory to my user account (which is also admin). This in turn made my alias to "sudo git" useless since I can now just use git without sudo. Hope this helps someone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .