忙活了一下午終於成功把代碼上傳到github上。
接下來就是我上傳代碼的步驟:
①首先注冊github賬號,登錄,創建新倉庫 ,點擊+,點擊new repository
得到如下頁面,填寫倉庫名,自己隨便寫一個名字,下面的描述可寫可不寫,點擊Initialize this repository with a README,然后創建:

②下載git shell,網上給了很多官網下載網址,我點進去下載,都下不下來,后我在百度上搜“git下載”,
下載下來也能用。這個是我下載的圖標:

③配置Git.
1.設置本地的ssh key,打開git bash,輸入命令:
ssh-keygen -t rsa -C "XXXXXX@XXXX.com" 其中雙引號中是你注冊github時用的郵箱。
一直回車,選擇默認路徑,和空密碼。最后會在默認路徑下生成.ssh文件夾,打開.ssh里面有兩個文件,打開id_rsa.pub復制里面的密鑰。
2.打開github,選擇settings

得到如下頁面,點擊ssh and gpg keys,選擇ssh keys 右邊的new ssh key。出現下面綠色框的內容,填寫標題,並將自己剛才復制的密鑰粘貼到key中。最后點擊add ssh key.

3.查看是否成功。在git bash中輸入命令:
ssh -T git@github.com
會提示,是否continue,輸入yes。后就會看到:
Warning:Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
Hi zhangsiyao11! You've successfully authenticated, but GitHub does not provide shell access.
這樣就成功了,不用理會warning。
ssh -T git@github.com
會提示,是否continue,輸入yes。后就會看到:
Warning:Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
Hi zhangsiyao11! You've successfully authenticated, but GitHub does not provide shell access.
這樣就成功了,不用理會warning。
4.克隆你剛才新建的倉庫到本地,輸入命令:
git clone https://github.com/zhangsiyao11/chat
后面的http是你的倉庫的地址。
此時會在剛才創建ssh key的默認目錄下生成以你倉庫名為文件名的文件,打開得到下圖所示:
git clone https://github.com/zhangsiyao11/chat
后面的http是你的倉庫的地址。
此時會在剛才創建ssh key的默認目錄下生成以你倉庫名為文件名的文件,打開得到下圖所示:

5.最后將你想要上傳的項目文件復制到上面的目錄:

6.在此處打開git bash,輸入如下命令:
git init
git add "文件名"
git commit -m "文件名"
如果出現讓你設置用戶名和用戶郵箱的提示,就按照提示上給的命令輸入即可。后再次執行上面commit的命令。
git remote add origin https://github.com/zhangsiyao11/chat http為你自己倉庫的地址
如果出現錯誤:
fatal: remote origin already exists
則執行以下語句:
git remote rm origin
再執行git remote add origin https://github.com/zhangsiyao11/chat即可。
git pull origin master
git push origin master
完成,再打開自己的倉庫就會出現剛剛上傳的項目文件:
git init
git add "文件名"
git commit -m "文件名"
如果出現讓你設置用戶名和用戶郵箱的提示,就按照提示上給的命令輸入即可。后再次執行上面commit的命令。
git remote add origin https://github.com/zhangsiyao11/chat http為你自己倉庫的地址
如果出現錯誤:
fatal: remote origin already exists
則執行以下語句:
git remote rm origin
再執行git remote add origin https://github.com/zhangsiyao11/chat即可。
git pull origin master
git push origin master
完成,再打開自己的倉庫就會出現剛剛上傳的項目文件:
