Git: protocol error: bad line length character
Tagged:  •  

Doing a git clone/pull/push command might result in the following error message:

Initialized empty Git repository in /home/bram/tmp/Filesystem/.git/
Password:
fatal: protocol error: bad line length character
fetch-pack from 'ssh://bram@xxx.xxx.xxx.xxx/home/bram/Filesystem' failed.

This is rather cryptic and it took some imagination to see where the problem was. The user bram is restricted to only one login on that machine. In this case, there was already a SSH session with that user on that machine, so no room anymore for a git operation. Closing down that session made git work again.

There may be other causes than this, but when you see this error, try logging in with the ssh command and see if that succeeds.

Ahh! This was the

Ahh! This was the information I needed to solve the problem. In my case the problem was actually that I had an 'echo' in my .bash_profile and .bashrc, which affected the protocol. Removing the echo fixed the problem.

This is extremely bad. Even

This is extremely bad. Even after removing all echos from .profile, it still fails with the same error. Only after removing echos from .bashrc does it work. However, .bashrc only gets loaded if it's an interactive shell. Why the shell invoked by git pull is interactive is beyond me...