第一次幫別人寫文檔,有點不會
按照貢獻說明來,先Fork了主倉庫,然后通過復制倉庫的http鏈接,
在Github Desktop上進行了快速的git clone一鍵式操作。
如需下載Github Desktop,我的是win-x64版本,請看👉 GitHubDesktop for Windows 、Atom最新版下載或者👉安利二十個程序員必備的軟件,款款都是精品
不過我這邊是錯誤的操作:應該復制git地址才行,不然得輸入密碼的。
因為git地址匹配你本地的密鑰,是安全的。但http地址沒有經過公開密鑰密碼體制驗證,所以在你寫完代碼想git push上傳代碼的時候,就會非常麻煩,要輸賬號,要輸密碼。
輸不對就停止不動了,就得自己ctrl+c停止當前進程,再重新git push,試對為止。很煩,我早就不記得我的gitee的Username和Password了
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過來的倉庫已經變動了,再去找原博主的倉庫,
在他的倉庫里點pull request,就可以開始PR協作了。【沒截圖】
最后我發出了PR請求,因為原博主說我可以隨便合並,所以我點擊了綠色按鈕:合並
於是我的代碼成功合並到了原博主的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!完工!