2021.9.6更新
這是18年寫的一篇文章了,今天在操作時,發現一些問題,需要同步更新一下, 主要是如下兩點。
文章更新內容:
1.github上創建的git branch的名字是main,不是原來的master, 第6步和第7步
git pull --rebase origin main
git push -u origin main
2.提交時需要使用PAT(personal access token)驗證,不是之前的用戶名加密碼
注意,在提交本地項目時,如果使用用戶名和密碼會有如下提示
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/wayne214/componentization_demo/'
根據提示,在github官網添加pat, 之後使用用戶名和pat就可以正常提交了
附:創建PAT鏈接
其實就幾個步驟:1.在電腦上創建一個新的文件夾 2、(先進入項目文件夾)通過命令 git init 把這個目錄變成git可以管理的倉庫
git init
3、把文件添加到版本庫中,使用命令 git add .添加到暫存區裏面去,不要忘記後面的小數點“.”,意爲添加文件夾下的所有文件
git add .
4、用命令 git commit告訴Git,把文件提交到倉庫。引號內爲提交說明
git commit -m 'first commit'
5、關聯到遠程庫(這裏我用的是HHS協議)
git remote add origin 你的遠程庫地址
如:git remote add origin [email protected]:wayne214/demo.git
如果執行到這步提示出錯信息:fatal: remote origin already exists 解決辦法:
1、先輸入$git remote rm origin
2、再輸入 $git remote add origin [email protected]:lily000000/demo.git 就不會報錯了!
6、獲取遠程庫與本地同步合併(如果遠程庫不爲空必須做這一步,否則後面的提交會失敗)
git pull --rebase origin master
7、把本地庫的內容推送到遠程,使用 git push命令。
git push -u origin master
最後,在github網站上就可以看到自己的項目了。
知也無涯,繼續努力。
加油。
--- End ---
君偉說
本文分享自微信公衆號 - 君偉說(wayne90214)。
如有侵權,請聯繫 [email protected] 刪除。
本文參與“OSC源創計劃”,歡迎正在閱讀的你也加入,一起分享。