標籤:blog exists images .com perm err one error: gre
【第一步】建立先倉庫
第一步的話看一般的提示就知道了,在github建立一個repository(Google可以解決),都是可視化的介面操作,所以難度不大。或者看這裡:https://help.github.com/articles/create-a-repo 這是官方help,雖然是英文的,但是基本都是圖和代碼,所以很容易讀懂。
在github首頁的右上方,點擊紅框中的Create New Repo。
進入建立倉庫的介面
填一下倉庫名稱,Initialize this repository with a README是可選的,不過本人建議最好選上,可以在後面省一個步驟。填好之後,點Create repository就行了。
【第二步】複製倉庫
第二步開始就基本進入命令列模式了,不過要先從github上下載命令列工具。:http://windows.github.com/
然後進行簡單的安裝之後,會在案頭上建立兩個表徵圖,GitHub和Git Shell,GitHub是圖形介面,git Shell是命令列模式,而且預設的Git倉庫是建在C盤的,個人建議要把路徑重設下。
點開Git Shell,進入命令列。首先我們先要把GitHub上的我們建立的倉庫clone下來,為了示範,我在GitHub上建立了一個名稱為myRepoForBlog的git。
在初始化版本庫之前,先要確認認證的公開金鑰是否正確,如下:
ssh -T [email protected]
正確地結果如下:
Warning: Permanently added ‘github.com,207.97.227.239‘ (RSA) to the list of known hosts. Hi findingsea! You‘ve successfully authenticated, but GitHub does not provide shell access.
會有一個Warning,不用理會。
接下對庫進行clone,如下:
git clone https://github.com/findingsea/myRepoForBlog.git
上面的地址可以在如下介面找到:
clone成功如下:
Cloning into ‘myRepoForBlog‘... Warning: Permanently added ‘github.com,207.97.227.239‘ (RSA) to the list of known hosts. remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done.
【第三步】上傳README.md檔案
這個時候,我們的GitHub檔案夾下就多了一個myRepoForBlog檔案夾,進入檔案夾目錄,對倉庫進行初始化,如果我們之前沒有勾選建立README,則要先建立README.md檔案,不然上傳檔案會報錯。如果在第一步就勾選過了,則可以直接進入第四步。
git init touch README.md git add README.md git commit -m ‘first_commit‘ git remote add origin https://github.com/findingsea/myRepoForBlog.git git push origin master
【第四步】push檔案
建立完README.md後,就可以push了,代碼類似。
git add . git commit -m ‘first_commit‘ git remote add origin https://github.com/findingsea/myRepoForBlog.git git push origin master
如果執行git remote add origin https://github.com/findingsea/myRepoForBlog.git,出現錯誤:
fatal: remote origin already exists
則執行以下語句:
git remote rm origin
再往後執行git remote add origin https://github.com/findingsea/myRepoForBlog.git 即可。
在執行git push origin master時,報錯:
error:failed to push som refs to.......
則執行以下語句:
git pull origin master
先把遠程伺服器github上面的檔案拉先來,再push 上去。
git遠程上傳檔案