【Git远程协做】Pull Request成功,并解决报错error: cannot spawn sh: No such file or directory

第一次帮别人写文档,有点不会
html

按照贡献说明来,先Fork了主仓库,而后经过复制仓库的http连接,git

在Github Desktop上进行了快速的git clone一键式操做。程序员

如需下载Github Desktop,个人是win-x64版本,请看👉 GitHubDesktop for Windows 、Atom最新版下载或者👉安利二十个程序员必备的软件,款款都是精品github

不过我这边是错误的操做:应该复制git地址才行,否则得输入密码的。vim

由于git地址匹配你本地的密钥,是安全的。但http地址没有通过公开密钥密码体制验证,因此在你写完代码想git push上传代码的时候,就会很是麻烦,要输帐号,要输密码。安全

输不对就中止不动了,就得本身ctrl+c中止当前进程,再从新git push,试对为止。很烦,我早就不记得个人gitee的Username和Password了ssh

D:\GitHub Project\awescnb-docs-guo>git add .

D:\GitHub Project\awescnb-docs-guo>git commit -m "青墟修改"
[master ddc289f] 青墟修改
 29 files changed, 12743 insertions(+), 12725 deletions(-)

D:\GitHub Project\awescnb-docs-guo>git push
error: cannot spawn sh: No such file or directory
Username for 'https://gitee.com': 用户名隐藏
Password for 'https://用户名隐藏@gitee.com':【在这里我按了ctrl+C终止】
fatal: could not read Password for 'https://用户名隐藏@gitee.com': No error

D:\GitHub Project\awescnb-docs-guo>git pull
Already up to date.

D:\GitHub Project\awescnb-docs-guo>git push
error: cannot spawn sh: No such file or directory
Username for 'https://gitee.com': 【在这里我按了ctrl+C终止】fatal: could not read Username for 'https://gitee.com': No error

D:\GitHub Project\awescnb-docs-guo>set GIT_SSH=G:\Git\usr\bin\ssh.exe

D:\GitHub Project\awescnb-docs-guo>git push
error: cannot spawn sh: No such file or directory
Username for 'https://gitee.com': fatal: could not read Username for 'https://gitee.com': No error

D:\GitHub Project\awescnb-docs-guo>git push -f
error: cannot spawn sh: No such file or directory
Username for 'https://gitee.com': 用户名隐藏
Password for 'https://用户名隐藏@gitee.com':


D:\GitHub Project\awescnb-docs-guo>git push -f 【这里强制推送也没用,由于我用的是http地址】
error: cannot spawn sh: No such file or directory
error: cannot spawn sh: No such file or directory
Username for 'https://gitee.com': 【在这里我按了ctrl+C终止】fatal: could not read Username for 'https://gitee.com': No error

关键步骤:
git配对远程仓库的origin分支
D:\GitHub Project\awescnb-docs-guo>git remote set-url origin git@gitee.com:用户名隐藏/awescnb-docs.git

git配对成功,由于本地的密钥是吻合远程的
D:\GitHub Project\awescnb-docs-guo>git push
Enumerating objects: 87, done.
Counting objects: 100% (87/87), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (41/41), done.
Writing objects: 100% (44/44), 50.07 KiB | 1.52 MiB/s, done.
Total 44 (delta 24), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-3.8]
To gitee.com:用户名隐藏/awescnb-docs.git
   efbfaba..ddc289f  master -> master

而后我fork过来的仓库已经变更了,再去找原博主的仓库,url

在他的仓库里点pull request,就能够开始PR协做了。【没截图】spa

最后我发出了PR请求,由于原博主说我能够随便合并,因此我点击了绿色按钮:合并debug

因而个人代码成功合并到了原博主的master里

不懂能够问,能够在“投喂”或者“留言板”里问。


方法来自【git和jupyter使用小技巧】👉 https://todebug.com/Tips/

若是你尚未克隆你的仓库,那你直接使用ssh协议用法:
git@github.com:yourusername/yourrepositoryname克隆就好了。
【很是建议,从远程仓库克隆,要用ssh方式clone】

🔯本文最重要的解决BUG方法

若是已经使用https协议克隆了,那么按照以下方法更改协议:
git remote set-url origin git@github.com:yourusername/yourrepositoryname.git

能够解决由于用https来clone而产生的报错error: cannot spawn sh: No such file or directory

缘由能够回看上文


若是你偏要用https协议来克隆

那能够进行以下操做,来帮助你省的每次都得填帐号密码

git push 免密码
通用状况
1.使用文件建立用户名和密码

文件建立在用户主目录下:

touch .git-credentials【这是建立一个.开头的隐藏文件】
vim .git-credentials
https://{username}:{password}@github.com

记得在真正输入的时候是没有大括号的。

2.添加git config内容

git config --global credential.helper store

执行此命令后,用户主目录下的.gitconfig文件会多了一项:[credential]

helper = store

从新git push就不须要用户名密码了。

Done!完工!

相关文章
相关标签/搜索