GIT - '~/repo.git/' is not a git command

余生长醉 提交于 2019-12-11 18:30:06

问题


I have a problem with with remote git repo and local repo (using SmartGit).

I'm creating remote repo on my server via ssh:

> cd ~
> git init repo.git
> cd repo.git
> touch readme
> git add .
> git commit -m "Initial commit"

From here everything seems perfect. Now I'm trying to clone repo using Smartgit with command

ssh://user@server:22/~/repo.git

Everything is cloning well. I make changes in readme file, saving it and trying to commit and push and getting error:

The remote end hang up unexpectedly
git: '~/repo.git' is not a git command. See 'git --help'

What am I doing wrong? Thank you.


回答1:


Use:

GIT_TRACE=2 git push origin master

and see what is happening to debug the issue.

Update:

It is trying git-receive-pack

Try doing below:

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

And then do the push again.

Other things you can try:

On the remote server setup a bare repo:

git init --bare

And then try cloning and pushing to it.




回答2:


I'd suggest using the full path instead of the home shortcut (~), e.g., git clone ssh://user@server/home/tuergeist/repo

This works for me on linux and also on WindowsXP in a git bash.

You also should obmit the .git extension, this may confuse your tools, as it expects a bare repository. (But I'm not sure)




回答3:


You don't need to specify port 22; that's the default port for SSH. Also, SSH is the default if you specify user@server:path.

Try cloning with just...

user@server:~/repo.git

instead.



来源:https://stackoverflow.com/questions/8427732/git-repo-git-is-not-a-git-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!