1.首先注冊github賬號,登錄,創建新倉庫 ,點擊+,點擊new repository
2.得到如下頁面,填寫倉庫名,自己隨便寫一個名字,下面的描述可寫可不寫,點擊Initialize this repository with a README,然后創建:
3.下載git shell,網上給了很多官網下載網址,我點進去下載,都下不下來,后我在百度上搜“git下載”,
1)下載完成后,傻瓜式安裝
2)配置git
3.設置本地的ssh key,打開git bash,輸入命令:
ssh-keygen -t rsa -C "XXXXXX@XXXX.com" 其中雙引號中是你注冊github時用的郵箱。
一直回車,選擇默認路徑,和空密碼。最后會在默認路徑下生成.ssh文件夾,打開.ssh里面有兩個文件,打開id_rsa.pub復制里面的密鑰。
4.打開github,選擇settings
得到如下頁面,點擊ssh and gpg keys,選擇ssh keys 右邊的new ssh key。出現下面綠色框的內容,填寫標題,並將自己剛才復制的密鑰粘貼到key中。最后點擊add ssh key.
5.查看是否成功。在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。
6.克隆你剛才新建的倉庫到本地,輸入命令:
git clone https://github.com/zhangsiyao11/package
后面的http是你的倉庫的地址。
此時會在剛才創建ssh key的默認目錄下生成以你倉庫名為文件名的文件,打開得到下圖所示:
7.最后將你想要上傳的項目文件復制到上面的目錄:
.在此處打開git bash,輸入如下命令:(注意:要進入到指定的倉庫(cd package)下面執行以下命令,不然的話會提示:fatal: pathspec '1.txt' did not match any files)
git init
git add "文件名"
git commit -m "文件名"
如果出現讓你設置用戶名和用戶郵箱的提示,就按照提示上給的命令輸入即可。后再次執行上面commit的命令。
8.git remote add origin https://github.com/zhangsiyao11/package http為你自己倉庫的地址
如果出現錯誤:
fatal: remote origin already exists
則執行以下語句:
git remote rm origin
再執行git remote add origin https://github.com/zhangsiyao11/package即可。
9.git pull origin master
git push origin master
完成,再打開自己的倉庫就會出現剛剛上傳的項目文件: