msysgit麻烦 [英] msysgit troubles

查看:109
本文介绍了msysgit麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我似乎有一些设置msysgit的真正问题。我可以通过腻子连接到我的SSH目录使用


ssh:// user @ host:port


我拥有正确的钥匙。我也可以通过使用plink来做到这一点
$ b


plink -P PORT user @ host -i /path/to/private_key.ppk


git clone ssh:// user @ host:port / path / to / myapp.git


I只是不断收到错误


在D:/Git/myapp.git

中初始化空的Git存储库警告:您似乎已经克隆了一个空的存储库。

fatal:远程终端意外挂断


/Git/setup.ini和TortiseGIT都使用


\程序文件\TortoiseSVN\bin\TortoisePlink.exe


有谁知道我可以如何解决这个问题,因为它让我疯狂!

解决方案

这是一个检查清单:


  1. 在您尝试连接的服务器上启用了ssh吗?

  2. 是否在服务器上安装了GIT?

  3. 服务器上是否有Git存储库设置?

  4. 存储库是否具有正确的权限并在服务器的配置中启用了共享库? b $ b
  5. 您是否在正确的地方使用ssh密钥?



    建议:


1:因为您可以使用putty进行连接,所以看起来像ssh设置好。



<2>:使用腻子并连接到服务器。输入 git --version 您是否收到合理的回应?如果没有,那么你将需要将其安装在服务器上。


<3>:尝试在服务器上设置新的存储库。假设它的* nix风格的服务器使用putty并连接到服务器并使用以下命令创建一个新的存储库,假设您有一个目录/ home / source_code。回声线只是使文件中有一点点文字,所以我们有一些东西可以开始。

  cd / home / source_code 
mkdir test_repo
cd / home / source_code / test_repo
回声第一个文件> t.txt
git init
git add。
git commit -m初始导入

现在我们有一个t库.txt文件在里面。作为一项规则,您绝不应将其推入包含对工作副本进行更改的存储库中。在服务器上建立一个存储库的目的是为了让人们能够一直推进它。我们做一个裸的克隆,它只是git数据库,这样就不可能有任何工作副本的变化。这是我们将用作中央git存储库的裸克隆。

  cd / home / source_code 
git clone --bare test_repo / test_repo.git

您现在可以摆脱我们设置的临时存储库。

  cd / home / source_code / 
rm -rf test_repo

在您的本地计算机上再次尝试克隆

  git clone ssh://user@host.com:port / home / source_code / test_repo.git 

4:权限:除非您为没有读权限的存储库选择了一个位置,否则这不会导致克隆,提取或拉取问题。如果在推送时出现Permission denied error,请参阅权限更正

<5>:为GIT设置公钥/私钥:


  1. 使用putty连接服务器
  2. 在〜/ .ssh文件夹中设置权限: chmod 700 .ssh

  3. 在〜/ .ssh / authorized_keys上设置权限: chmod 600 authorized_keys

  4. 生成密钥 ssh-keygen -t dsa

  5. 接受要使用的文件名称

  6. 不要输入密码(只需输入)。您将需要稍后使用密码重做此功能。

  7. 将pub密钥添加到authorized_keys文件中: cat id_dsa.pub>> .ssh / authorized_keys

  8. 编辑/ etc / ssh / ssh_config并添加行 PubkeyAuthentication yes

  9. 重新启动ssh守护进程 sudo /etc/init.d/ssh restart

  10. 复制 id_dsa id_dsa.pub 从服务器到您的本地硬盘(使用winscp或sftp或某些此类工具)c:\\ \\ users \\ usersName \ .ssh目录(这是vista的位置将有点与其他版本的Windows不同)

  11. 设置tortoise git指向C:\ Program Files \Git\bin\ssh.exe(不是腻子)

命令行git和tortoise git应该被设置上班。在本地机器上再次尝试克隆。

  git clone ssh://user@host.com:port / home / source_code / test_repo.git 

您现在可能想要使用密码重复设置密钥....


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!

解决方案

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://user@host.com: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://user@host.com:port/home/source_code/test_repo.git

You might now want to go and repeat setting up the keys with a passphrase....

这篇关于msysgit麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆