msysgit troubles

10,801

Solution 1

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

Solution 2

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

Share:
10,801
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    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!

  • Admin
    Admin over 14 years
    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.
  • Admin
    Admin over 14 years
    even when i run git push ssh://user@host:port/path/to/myapp.git - i just get "fatal: the remote end hung up unexpectedly"
  • Admin
    Admin over 14 years
    is there any way to debug in "GIT" ? i.e. trace or something ? how to get this into the output ?