2012-03-12 43 views
8

我有一個Windows 2008 R2服務器標準版。我有FreeSSHd與Git一起安裝。 Windows防火牆的例外設置爲端口22.我的SSH服務器設置爲僅接受SSH公鑰。我可以使用終端(如ssh [email protected])正常登錄到服務器。當我去使用git clone命令(例如git clone ssh://[email protected]/path_to_my_repo)我得到這個錯誤:致命的:協議錯誤:壞行長度字符:Unab

fatal: protocol error: bad line length character: Unab

我是一個絕對的損失是什麼導致了它。我有Shell,SFTP和隧道協議啓用。

+2

也許這樣? HTTP://計算器。com/questions/8170436/git-remote-error-fatal-protocol-error-bad-line-length-character-unab – ellotheth 2012-05-23 19:01:28

回答

4
+1

遲到的迴應,但我想我會提到使用WinSSHD的上述指南爲我工作。我爲我們的團隊實施了三層Dev,QA和PRD系統。完美滿足我們的需求。 – gwrichard 2013-04-09 20:00:14

2

通過SSH的Git使用SSH管道的輸出逐字。如果該輸出包含任何與git無關的僞造數據,那麼git命令將無法解析該數據,並會以一個模糊的錯誤消息中止。例如,如果你有一個連接時顯示內容的用戶腳本,或者某些東西會拋出git未理解的錯誤消息,就會發生這種情況。

你會注意到'Unab'看起來像'Unable'的開始,大概是一個對於人類而言是錯誤的信息,而不是git。

運行以下命令時會發生什麼?

ssh [email protected] git-upload-pack '/path_to_your_repo' 

從理論上講,您應該會收到一條以'Unable'開頭的錯誤消息。例如,'無法找到git-upload-pack'。在這種情況下,解決方法是將git-upload-pack添加到您的路徑中!

0

今天我有同樣的問題,在我的工作......所以我發現這一點:Setting up a Git Server on Windows Server 2008 R2

你需要看到什麼是如下:

Making Git work on the server:

  1. If not already done, install msysgit on your server (I would recommend to install it directly to C:\Git or at least a path that has no spaces because I had some weird issues with 「spaced」 paths)

  2. Add C:\Git\bin to the PATH variable. This is very important!! sh.exe and other dependencies are in this folder

  3. Now go to C:\Git\bin and add the following two files

gup.sh grp.sh 4. Open gup.sh in your favorite editor and insert

C:/Git/libexec/git-core/git-upload-pack.exe $* 5. Open grp.sh and insert

C:/Git/libexec/git-core/git-receive-pack.exe $* The $* essentially rips off the single quotes from the repository path argument, so a path that has spaces in it won’t work here either I guess

Basically we’re done now and all git operations from the client should work. For a clone you have to type

git clone -u 'sh gup.sh' ssh://[email protected]/path/to/myrepo.git or a push would be

git push --exec 'sh grp.sh' ssh://[email protected]/path/to/myrepo.git but that is not very elegant.

Cleaning things up:

  1. At first we want to get rid of the whole repo path by specifying a remote alias

git remote add origin ssh://[email protected]/path/to/myrepo.git Where 「origin」 would be the alias name

  1. Next we set the config for the git-upload-pack and git-receive-pack so we don’t have to reference the shell script all the time.

git config remote.origin.uploadpack 'sh gup.sh' and

git config remote.origin.receivepack 'sh grp.sh' That’s it. Now we can use the normal git commands without any additional parameters:

git clone origin git push origin master git pull origin ...

0

就我而言,我有一個

echo $HOSTNAME 

在我的.bashrc和.bash_profile,我用來診斷一些連接問題。這給了我信息:

fatal: protocol error: bad line length character: [VSR 

當我試圖從ssh回購git pull。刪除echo聲明使事情工作; '[VSR'只是echo的前4個字符。