2

I've just initialized a GIT repo in an existing website root. I have a local development copy of this site, which is already a GIT repo. I can't just clone one from the other, as the local/live versions have fallen out of sync over the years.

I'm trying to get them lined back up with GIT again, but I want to be able to do a fetch on the live site and run git diff

My problem is, on the local site I've added the live site as a remote repo:

git remote add live [email protected]:/path/to/repo 

I can successfully log in via ssh to my server:

ssh [email protected] 

But when I try to fetch, and type in the ssh password, the command line just returns the password prompt, as if I've typed it wrong. But I know the password is correct, as I can use SSH to log in.

Do I have to specify ssh:// before my remote URL? Is there something I have to do to get ssh remote repos working

UPDATE

I've added the ssh:// prefix, but it's made no difference. This is how it looks in .git/config

[remote "live"] url = ssh://[email protected]/path/to/repo fetch = +refs/heads/*:refs/remotes/live/* 

Running GIT_TRACE=true git fetch live adds in the lines:

trace: run_command 'ssh' '[email protected]' 'git-upload-pack '\''/path/to/repo'\''' 

I have to type the password in 3 times before I get the message:

fatal: the remote end hung up unexpectedly 
14
  • did you initialized with '--bare' option? Commented May 2, 2012 at 8:53
  • On the live site, no. Not sure what the difference is between "git init" and "git init --bare" Commented May 2, 2012 at 8:56
  • as @tigran said, you need to build a repo on the live server with --bare flag. about the difference, you can read it from here: progit.org/book/ch4-2.html Commented May 2, 2012 at 9:06
  • The website is live though, I'm turning an existing set of files into a repository. Doesn't that mean the working directory isn't empty? Or the site root is the working directory? Commented May 2, 2012 at 9:11
  • I assume the ssh user has full permissions on the server-side repo, path and files? Commented May 2, 2012 at 9:25

3 Answers 3

2

I think you're missing an alias for the remote.

git remote add origin [email protected]:/path/to/repo 

Note the origin bit.

Is the .git/config you posted accurate? If it is, try changing the remote url from

url = ssh://[email protected]/path/to/repo

to

url = [email protected]:/path/to/repo

Note the : separating the server name from the server path.

Sign up to request clarification or add additional context in comments.

3 Comments

I've got "live" as the alias, I've updated my question to show the config file.
Adding the : gives me "ssh: Could not resolve hostname server.co.uk:: Name or service not known fatal: The remote end hung up unexpectedly"
OK, I can reproduce your error now actually, which is encouraging. I can reproduce it with a url like ssh://[email protected]:/path/to/repo but not with a url like [email protected]:/path/to/repo. I have again amended the answer above. Try with a url string in .git/config like [email protected]:/path/to/repo. To be clear, the ssh:// part is dropped and the colon separating the server from the path is preserved.
0

yes, you need ssh://. Just change it in .git/config file:

url = ssh://[email protected]:/path/to/repo 

4 Comments

I have the same setup and I don't need the ssh:// prefix. Can you elaborate on why he needs it?
Tried it with and without, gives the same response, just keeps asking for the password
try to run git on remote host: ssh [email protected] "git --version"
ssh [email protected] "git --version" works fine, returns "git version 1.7.4.1"
0

Following only applys if you have shell access to the server. Probably not what you want but incase you want to try set up a public/private key auth. Simply generate a RSA keypair with command :

ssh-keygen -t rsa I would reccomend you to use a passphrase since you can store it in ssh-agent after generating a keypair copy the public key over to your server you can use scp :

scp -p ~/.ssh/id_rsa.pub host:~/.ssh/ and then in server do cat id_rsa.pub >> authorized_keys

2 Comments

I did wonder if GIT just doens't work without SSH keypairs, but ssh [email protected] "git --version" seems to work ok without. I might give this a try though
Git does work without keypairs but I always set it up using SSH keypairs it just makes my life 10 times easier.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.