3

Trying to push to a git repository, I got the error fatal: protocol error: bad line length character: logi. I was able to run git clone just fine, it's only the push that didn't work.

Tools involved:

  • Git for Windows
  • Plink
  • Pageant

Per this answer, I tried plink <site> git-receive-pack <directory> but got fatal: bad argument. So did others who were able to successfully push to the repo.

My permissions were the same as other people who could push to the repo.

Another person tried Git for Windows and it worked fine for them.

I've been able to successfully push to SVN via the Eclipse plugin on the very same host, using the very same SSH key.

Running Plink in verbose mode, I verified that it was retrieving the correct key from Pageant.

pmcnet
  • 51
  • 1
  • 1
  • 7

6 Answers6

3

I overcame this issue by putting my username in front of the host-name. e.g.

git clone ssh://github.com/organization/repo

becomes

git clone ssh://git@github.com/organization/repo
2

So here's the solution that finally worked for me, after weeks of frustration and searching: Reinstall Git for Windows, only set it to use the ssh.exe it brings with it, rather than Plink. I never did find out what the full underlying error was, and Plink has worked fine for me otherwise, but that solved it.

pmcnet
  • 51
  • 1
  • 1
  • 7
1

I received the same error by omitting the key id. For instance:

git clone ssh://git-codecommit.us-west-2.amazonaws.com/v1/repos/xxxxxx

Give me the problem you inquire about

git clone ssh://APK-----------@git-codecommit.us-west-2.amazonaws.com/v1/repos/XXXXXXX

Makes it all work well

1

I have another angle to add, which I don't see above. If you have a chatty .bashrc or .login file on the remote (server) side, this can interfere with communications. For example, I was getting this mysterious error. (Note: I'm not ssh'ing to localhost; I'm actually tunneling through a wrapper script).

rcook@linode:~/current_projects$ git clone -vvv ssh://rcook@localhost:/Volumes/2_TB_SSD_external/current_projects_2TB/gitrepos/RC_bash_lib RC_bash_lib.new
Cloning into 'RC_bash_lib.new'...
Password:
fatal: protocol error: bad line length character: sour

Huh? Something is sour? What it was, is that in my .bashrc file on the remote host I had this line:

echo sourcing bashrc

... as a debugging tool. I forgot to turn it off, and it broke my git sessions. Hope this helps some other poor fool.

Rich
  • 926
  • 8
  • 17
0

I've come across this issue on Windows when using the ssh protocol and a submodule with putty/plink. The .gitmodules file does not specify the protocol or the user, just the domain and repo. We only seem to have issues when using plink (gitbash on Windows is fine, no issues on Linux or MacOS):

[submodule "my_module"]
    path = my_module
    branch = branch_name_1
    url = git.ourgitserver.com:the_module.git

If I attempt to do git submodule init and git submodule update I get the error.

fatal: protocol error: bad line length character: logi

The solution is to correct the .gitmodules url BEFORE you init. There does not seem to be a way to fix the issue after an init.

So delete the local directory of the main repository then do a git clone .... Immediately open .gitmodules and add the user git@:

[submodule "my_module"]
    path = my_module
    branch = branch_name_1
    url = git@git.ourgitserver.com:the_module.git

THEN do a git submodule init and carry on as normal. I don't actually save that change to the .gitmodules file because, well, I'm not allowed. You can just checkout (remove) the changes again and curse the people that won't let you update the .gitmodules file. Once initialized correctly, the problem does not re-occur.

Dinsdale
  • 581
  • 7
  • 12
0

If it is a new project, you can delete your git folder that is hidden on your folder project. Then instead of Ctrl+C Ctrl+V the HTTPS, try typing it on GitBash. I had this problem using windows. I believe there is a character issue when copying/pasting.