git-receive-pack: command not found

2019-04-30 19:46发布

I'm trying to use Git to push to my remote server, but it keeps saying git-receive-pack: command not found. I tried searching and some people say its the server, others say it's the client.

OS: Windows 8 64bit Server: Cent OS with CPanel newest version

Git is built in to CPanel, I didn't install it.

http://imgur.com/Gg7uGcF,acp26eE

Maybe if I knew which system was saying the error I could troubleshoot it better. Also, I know nothing about SSH. I tried inserting the SSH key that was generated by GIT but when I tried using SSH:// it would still just ask for the password. So something might not be setup correctly. I added the git user to the system with the repository like the git instructions said to do, but I added a password to the user just to see if it would let me login without SSH.

标签: git ssh
2条回答
你好瞎i
2楼-- · 2019-04-30 20:32

When you run git push the send-pack part of the protocol is running on your, local side, and it connects to the receive-pack part running on the remote side.

So let's say you run git push, where your remote origin repo is configured to use ssh and is mapped to server.com. Git uses send-pack to initiate a connection over ssh to the server extracted from the remote URL *:

$ ssh server.com "git-receive-pack /path/to/repo.git"

* When the repository was previously cloned or added as git remote add origin ssh://server.com/path/to/repo.git

Note that the quoted command is run by ssh on the remote server, and it is possible that git-receive-pack could not be located there. You can test for this yourself as follows:

$ ssh server.com "type -p git-receive-pack" || echo "git-receive-pack not found"

If indeed the git-receive-pack command could not be located on the remote - for instance, because it is not in the PATH of your remote login shell, you can tell git push where it should look for it by running:

$ git push --receive-pack=/server/com/full/path/to/git-receive-pack

And you can save typing that every time you push by telling git to remember to use the explicit path via the config:

$ git config remote.origin.receivepack /server/explicit/path/to/git-receive-pack
查看更多
可以哭但决不认输i
3楼-- · 2019-04-30 20:32

The real answer is that even though I put

alias git-receive-pack="/usr/local/cpanel/3rdparty/bin/git-receive-pack"

I still need to add it to my ~/.bashrc

export PATH=$PATH:"/usr/local/cpanel/3rdparty/bin"

Also, on a side note the whole stdin: is not a TTY error can be fixed by removing the /home/git/.bashrc file.

As stated in: http://webhostingneeds.com/Git_stdin_is_not_a_tty

查看更多
登录 后发表回答