克隆操作正常,但远程推送无法完成。远程仓库在copssh上。

10

我已经按照Tim Davis的指南,"在Windows上使用Copssh和msysGit搭建服务器",现在正在学习如何使用git命令,按照Jason Meridth的指南,一切都运行良好,但是我现在无法通过push命令。

我已经将服务器和客户端设置在同一台机器上(目前是win7-x64)。

这里是一些有关设置的信息:

CopSSH Folder     : C:/SSH/
Local Home Folder : C:/Users/rvc/
Remote Home Folder: C:/SSH/home/rvc/          # aka /cygdrive/c/SSH/home/rvc/
git remote rep    : C:/SSH/home/rvc/myapp.git # empty rep

在 '/SSH/home/rvc/.bashrc' 和 'Users/rvc/.bashrc' 路径下:

export HOME=/cygdrive/c/SSH/home/rvc
gitpath='/cygdrive/c/Program Files (x86)/Git/bin'    
gitcorepath='/cygdrive/c/Program Files (x86)/Git/libexec/git-core'
PATH=${gitpath}:${gitcorepath}:${PATH}

所以,克隆操作可以完成(以下所有操作均在 "Git Bash here" 中完成:P):

rvc@RVC-DESKTOP /c/code
$ git clone ssh://rvc@192.168.1.65:5858/SSH/home/rvc/myapp.git
Initialized empty Git repository in C:/code/myapp/.git/
warning: You appear to have cloned an empty repository.

rvc@RVC-DESKTOP /c/code
$ cd myapp

rvc@RVC-DESKTOP /c/code/myapp (master)
$ git remote -v
origin  ssh://rvc@192.168.1.65:5858/SSH/home/rvc/myapp.git (fetch)
origin  ssh://rvc@192.168.1.65:5858/SSH/home/rvc/myapp.git (push)

然后我创建了一个文件:

rvc@RVC-DESKTOP /c/code/myapp (master)
$ touch test.file

rvc@RVC-DESKTOP /c/code/myapp (master)
$ ls
test.file
尝试推送它并获得此错误:

Try to push it and get this error:

rvc@RVC-DESKTOP /c/code/myapp (master)
$ git add test.file

rvc@RVC-DESKTOP /c/code/myapp (master)
$ GIT_TRACE=1 git push origin master
trace: built-in: git 'push' 'origin' 'master'
trace: run_command: 'C:\Users\rvc\bin\plink.exe' '-batch' '-P' '5858' 'rvc@192.1
68.1.65' 'git-receive-pack '\''/SSH/home/rvc/myapp.git'\'''
git: '/SSH/home/rvc/myapp.git' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly

"git: '/SSH/home/rvc/myapp.git' 不是一个 git 命令。请参见 'git --help'。" 什么?!

编辑: 愤怒!!

我现在遇到了同样的问题,但是现在是使用 ssh:

rvc@RVC-DESKTOP /c/code/myapp (master)
$ GIT_TRACE=1 git push
trace: built-in: git 'push'
trace: run_command: 'ssh' '-p' '5858' 'rvc@192.168.1.65' 'git-receive-pack '\''/
SSH/home/rvc/myapp.git'\'''
git: '/SSH/home/rvc/myapp.git' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly

我尝试了GUI push,显示相同的消息。

git: '/SSH/home/rvc/myapp.git' is not a git command. See 'git --help'.
Pushing to ssh://rvc@192.168.1.65:5858/SSH/home/rvc/myapp.git
fatal: The remote end hung up unexpectedly

以下是当前的 .bashrc 文件:

C:\Users\rvc.bashrc (我认为这只在cygwin/git bash中使用):

export HOME=/c/SSH/home/rvc

gitpath='/c/Program Files (x86)/Git/bin'

gitcorepath='/c/Program Files (x86)/Git/libexec/git-core'
export GIT_EXEC_PATH=${gitcorepath}

PATH=${gitpath}:${gitcorepath}:${PATH}

C:\SSH\home\rvc.bashrc(..当Git通过SSH连接到“远程”服务器时使用):

export HOME=/c/SSH/home/rvc

gitpath='/cygdrive/c/Program Files (x86)/Git/bin'

gitcorepath='/cygdrive/c/Program Files (x86)/Git/libexec/git-core'
export GIT_EXEC_PATH=${gitcorepath}

PATH=${gitpath}:${gitcorepath}:${PATH}

编辑2: 一些额外的信息:

rvc@RVC-DESKTOP /c/code/myapp (master)
$ ssh -p 5858 rvc@192.168.1.65 git-receive-pack /SSH/home/rvc/myapp.git
git: '/SSH/home/rvc/myapp.git' is not a git command. See 'git --help'.
编辑 3:

rvc@RVC-DESKTOP /c/code/myapp (master)
$ git push --receive-pack='git receive-pack' ssh://rvc@192.168.1.65:5858/SSH/home/rvc/myapp.git --a
ll
Counting objects: 3, done.
Writing objects: 100% (3/3), 202 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://rvc@192.168.1.65:5858/SSH/home/rvc/myapp.git
 * [new branch]      master -> master

这个方法有效吗?

git push 运行的是 'git-receive-pack',正确应该是 'git receive-pack' 吗?

我的 git 版本是 'git version 1.7.0.2.msysgit.0'

4个回答

11

愚蠢的修正(更改了/SSH/home/rvc/.gitconfig):

rvc@RVC-DESKTOP /c/code/myapp (master)
$ git config --global remote.origin.receivepack "git receive-pack"

rvc@RVC-DESKTOP /c/code/myapp (master)
$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 246 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
To ssh://rvc@192.168.1.65:5858/SSH/home/rvc/myapp.git
   680f32e..2da0df1  master -> master

1

谢谢!我也遇到了这个错误

git: '/pathToRepo/myRepoName.git' is not a git command See 'git --help'.
fatal: The remote end hung up unexpectedly

git config 命令对我有用。

git config --global remote.origin.receivepack "git receive-pack"

我正在运行MSysGit-1.7.3.1


1

找到了答案...

GIT_SSH

If this environment variable is set then git fetch and git push will

use this command instead of ssh when they need to connect to a remote system. The $GIT_SSH command will be given exactly two arguments: the username@host (or just host) from the URL and the shell command to execute on that remote system.

To pass options to the program that you want to list in GIT_SSH you

will need to wrap the program and options into a shell script, then set GIT_SSH to refer to the shell script.

Usually it is easier to configure any desired options through your

personal .ssh/config file. Please consult your ssh documentation for further details.

我只是不得不从Windows环境变量中删除GIT_SSH变量。

我之前设置了它,因为我在按照Tim Davis的指南操作,但是没有使用TortoiseGit, 而该指南建议将变量指向TortoisePlink(步骤4.4),因此我假设我必须 将其指向plink.exe :P。好吧..继续下一个问题...


1

1) 这个问题最常见的原因是 - 打开Git Bash窗口并输入echo $HOME - 确保它设置为/c/SSH/Home/<user>/。如果不是,请输入export HOME=/c/SSH/home/<user>

2) 尝试GUI界面[同样的问题?]


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接