git 无法推送到 Github,无法生成 sh:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22619355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trouble pushing to Github, cannot spawn sh: No such file or directory
提问by Will Nasby
I'm having a difficult time pushing to Github..I have a repository that I had cloned, and I have made changes to it that I'd like to push back to github.
我很难推送到 Github ..我有一个我已经克隆的存储库,我已经对其进行了更改,我想将其推送回 github。
While in the repository, I do the following:
在存储库中,我执行以下操作:
git add *
Which seems to work as I get no response, then when I do:
这似乎有效,因为我没有得到回应,然后当我这样做时:
git commit -m "test"
I get the response:
我得到回应:
On branch Will_branch
nothing to commit, working directory clean
which I expect is where my problem starts.
我期望这是我的问题开始的地方。
When I do:
当我做:
git push origin master
git push origin my_branch
I get the error:
我收到错误:
cannot spawn sh: No such file or directory
cannot spawn git: No such file or directory
I have gone through so many guides to no avail..thanks for any help.
我已经通过了这么多指南无济于事..感谢您的帮助。
回答by u1860929
This might be happening due to a large number of tags in your repo. Check this google-group entry, this questionand another google group entry.
这可能是由于您的存储库中有大量标签而发生的。检查此 google-group entry、this question和另一个 google group entry。
Basically, this is a known issue with msysgit
and users on google group suggest using the ssh protocol instead as workaround:
基本上,这是一个已知问题,msysgit
谷歌组上的用户建议使用 ssh 协议作为解决方法:
- Uninstall Git (this doesn't uninstall your existing repositories or SSH keys you've generated)
- Reinstall git at
C:\Git
- Open git bash
- run this command:
export GIT_SSH=/c/Git/bin/ssh.exe
- 卸载 Git(这不会卸载您现有的存储库或您生成的 SSH 密钥)
- 重新安装git
C:\Git
- 打开 git bash
- 运行这个命令:
export GIT_SSH=/c/Git/bin/ssh.exe
Also, the commit response you are getting suggests nothing got committed, do a git log
to check if the commit actually happened.
此外,您收到的提交响应表明没有提交任何内容,请git log
检查提交是否实际发生。
Another reason, as mentioned in this msysgit
ticketcould be the presence of spaces in your Environment variables. Moving the installation of msysgit
etc to C:
instead of C:\Program Files
may solve it.
另一个原因,因为在此提到的msysgit
票可能是空间中的环境变量的存在。将msysgit
etc的安装移动到C:
而不是C:\Program Files
可以解决它。
回答by NaturalBornCamper
The offered solution didn't work for me, what I had to do was reinstall Git with one important thing: Make sure to select "Attribute .sh files to git" during the install process and it seems to be all good now.
提供的解决方案对我不起作用,我必须做的是用一件重要的事情重新安装 Git:确保在安装过程中选择“Attribute .sh files to git”,现在看起来一切都很好。
回答by Kapil Garg
I had the same issue in IntelliJ IDE, what worked for me is to change the access of Git repository from private to public.
我在 IntelliJ IDE 中遇到了同样的问题,对我有用的是将 Git 存储库的访问权限从私有更改为公共。
回答by hen
I had the same issue with CLion on Windows 10 when trying to clone from a private repository on gitlab. However, the error vanished without reinstalling, when I added the git binary path (C:\Program Files\Git\bin
for me) to the PATH variable.
尝试从 gitlab 上的私有存储库克隆时,我在 Windows 10 上遇到了与 CLion 相同的问题。但是,当我将 git 二进制路径(C:\Program Files\Git\bin
对我而言)添加到 PATH 变量时,该错误没有重新安装就消失了。