Reputation:
So I seem to have some real issues setting up msysgit. I can connect via putty to my SSH directory using
ssh://user@host:port
And I have the correct keys. I can also do this using plink via the
plink -P PORT user@host -i /path/to/private_key.ppk
When I attempt to run (via TortiseGIT) or via a git bash
git clone ssh://user@host:port/path/to/myapp.git
I just keep getting the error
Initialized empty Git repository in D:/Git/myapp.git
warning: You appear to have cloned an empty repository.
fatal: The remote end hung up unexpectedly
I have checked bot /Git/setup.ini and TortiseGIT and both use
C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe
Does anyone know how I can fix this problem as its driving me nuts!
Upvotes: 7
Views: 10848
Reputation: 1743
Here is a bit of a check list:
Do you have the ssh keys in the right place for GIT?
Suggestions:
1: Since you can connect using putty, looks like ssh is setup ok.
2: Use putty and connect to the server. Type in git --version
Do you get back a reasonable response? If not then you will need to install it on the server.
3:Try setting up a new repository on the server. Assuming its a *nix style server use putty and connect to the server and make a new repository using the following commands, assuming you have a directory /home/source_code. The echo line just makes a file with a little bit of text in it so we have something to start with.
cd /home/source_code
mkdir test_repo
cd /home/source_code/test_repo
echo "first file" > t.txt
git init
git add .
git commit -m "Initial Import"
So now we have a repository with one t.txt file in it. As a rule you should never push into a repository that contains changes to the working copy. The purpose of having a repository on the server is so that people can push into it all the time. We make a "bare" clone which is only the git database, that way there is no possibility of any working copy changes. It is this "bare" clone that we will use as the central git repository.
cd /home/source_code
git clone --bare test_repo/ test_repo.git
You can now get rid of the temporary repository that we set up.
cd /home/source_code/
rm -rf test_repo
On your local computer try cloning again
git clone ssh://[email protected]:port/home/source_code/test_repo.git
4: Permissions: This should not cause a problem with cloning, fetching or pulling, unless you have selected a location for the repository that doesnt have read access. If you get a Permission denied error when pushing back then refer to Permissions correction
5: Setting up public/private key for GIT:
chmod 700 .ssh
chmod 600 authorized_keys
ssh-keygen -t dsa
cat id_dsa.pub >> .ssh/authorized_keys
PubkeyAuthentication yes
sudo /etc/init.d/ssh restart
id_dsa
and id_dsa.pub
from the server to your local hard drive (use winscp or sftp or some such tool) c:\users\userName\.ssh directory (this is for vista the location will be a bit different for other versions of windows)Both the command line git and tortoise git should be setup to work. Try cloning again on your local machine.
git clone ssh://[email protected]:port/home/source_code/test_repo.git
You might now want to go and repeat setting up the keys with a passphrase....
Upvotes: 9
Reputation: 962
Have you tried connecting from Git-Bash with ssh user@host:port? Does it connect directly or ask for a password?
Port is only required if you are using a non-standard port for ssh otherwise it will default to 22. It is one thing from Putty but make sure you can connect from git bash because it will generally have its own key store in a .ssh directory off of your user directory. If you cannot get that to work from Git-Bash you need to fix the key or debug where the problem is, try specifying the key by using
ssh -i keyfile user@host:port
if that doesn't work or prompts you for a password on the remote machine it means the key exchange is not working properly. So you need to go through checking the keys are setup properly with regards to the Git-Bash environment. In particular make sure that you have exported the RSA key and are not just using the ppk key with Git-Bash. I do not believe that is supported. I don't use Tortoise-Git so I can't help with that, but I do use Git Bash regularly.
Upvotes: 0
Reputation:
Is there anything (i.e. at least one commit) in the remote repo ?
git says: "warning: You appear to have cloned an empty repository"
and when you want to push into the empty remote repo you have to use:
git push URL master
Upvotes: 0
Reputation: 4251
You need to install Pageant and add the key into it.
Also double check that your GIT_SSH environment variable is set up to use plink
Upvotes: 1