tags:

views:

1859

answers:

5
+3  Q: 

msysgit troubles

Hi,

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!

+1  A: 

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

nolim1t
hey thanks for the response - yes, I have pageant running and the key is loaded into it. the GIT_SSH environment variable (via /Git/setup.ini) is set to the path as above.
even when i run git push ssh://user@host:port/path/to/myapp.git - i just get "fatal: the remote end hung up unexpectedly"
is there any way to debug in "GIT" ? i.e. trace or something ? how to get this into the output ?
A: 

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
thanks for the response. yeah i am not sure that is the issue because even when i push i still get the error. how can i "debug" git or plink ? do you have any idea?
Ehh...You are not sure that this is the issue ?I thought you can't push into that repo ? (see comment to answer of nolim1t)
You could try setting GIT_TRACE=1 and 'git ls-remote Your-URL'
hey thx again - where do I set GIT_TRACE=1 ?
Through My Computer->Properties (I don't remember which tab as I don't have a windows machine in front of me now), but there is a button called environment variablee.That way you can see and set any variable in windows
nolim1t
You would simply do 'export GIT_TRACE=1 ; git ...' in the msysgit bash. No need to make that setting permanent.
A: 

Q: Where do I set GIT_TRACE=1 A: Where do you do 'git ....' ?

Stefan Näwe
A: 

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.

naven87
+2  A: 

Here is a bit of a check list:

  1. Is ssh enabled on the server you are trying to connect to?
  2. Is GIT installed on the server?
  3. Do you have a Git repository set-up on the server?
  4. Does the repository the correct permissions and have sharedrepository enabled in the config on the server?
  5. 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:

  1. Connect to the server with putty
  2. Set permissions on your ~/.ssh folder: chmod 700 .ssh
  3. Set permissions on your ~/.ssh/authorized_keys: chmod 600 authorized_keys
  4. Generate the keys ssh-keygen -t dsa
  5. Accept the file names it wants to use
  6. Don't enter a passphrase (just enter). You will want to redo do this with a passphrase later.
  7. add the pub key to the authorized_keys file: cat id_dsa.pub >> .ssh/authorized_keys
  8. edit /etc/ssh/ssh_config and add the line PubkeyAuthentication yes
  9. restart the ssh daemon sudo /etc/init.d/ssh restart
  10. Copy 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)
  11. Set tortoise git to point to C:\Program Files\Git\bin\ssh.exe (not putty)

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....

daniel