git push origin master: 'D:/Projects/TheProject' is not a git command

馋奶兔 提交于 2020-01-04 13:44:59

问题


I've got two machines running cygwin ssh with msysgit. I've cloned a git repository from my desktop to my laptop as described in 'X' does not appear to be a git repository (I'm sure the path is correct). This leaves me with a .git/config as follows:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = GitServer:D:/Projects/TheProject
[branch "master"]
    remote = origin
    merge = refs/heads/master

The clone worked great. git pull origin works great. But if I try to "git push origin master" I get the following error:

$ git push origin master
MyUser@TheDesktop's password:
git: 'D:/Projects/TheProject' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly

Any ideas about a fix for this?


回答1:


http://www.cygwin.com/cygwin-ug-net/using.html#cygdrive recommends against using the "D:/" syntax and suggests using "/cygdrive/d/" instead.

It looks like cygwin doesn't have chsh but you could set your shell to git-shell manually in your cygwin.bat.




回答2:


You can use cygwin urls : use /d/Projects/TheProject instead of D:/Projects/TheProject




回答3:


The accepted answer to this question fixed it for me, specifically this:

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



回答4:


First run this on client: git config --global remote.origin.receivepack "git receive-pack"

CD into your local repository: cd mylocalrepo

Assuming server side path == c:\gitpub\myproj.git, then to pull/push to server git fetch user@remoteserver.com:c:/gitpub/myproj.git master git push user@remoteserver.com:c:/gitpub/myproj.git master

Of course you can add a remote shortcut: git remote add myremote user@remoteserver.com:c:/gitpub/myproj.git

and then: git fetch myremote master git push myremote master

For more information on setup of cygwin/ssh server, here's a post I wrote that discusses setting up a shared GIT repository on a Windows Server instance running in the Amazon EC2 cloud:

http://cacheattack.blogspot.com/2012/05/installing-git-server-on-amazon-ec2.html




回答5:


I've switched to using cygwin's version of git, as mentioned in ak2's comment. It all works now.

But I do remember why I avoided cygwin git in the first place... it often (several times a day) errors when using git svn. I end up having to kill off all my cygwin processes and running "ash rebaseall" to fix it, or rebooting my machine. It's very frustrating.



来源:https://stackoverflow.com/questions/5795013/git-push-origin-master-d-projects-theproject-is-not-a-git-command

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