標籤:
1.首先到github.com註冊使用者;
2.下載git,地址:http://pan.baidu.com/s/1skPpWlB(64位下載);http://pan.baidu.com/s/1skOAa77 (32位下載)
3.按照預設安裝即可;
4.開始菜單裡找到“Git”->“Git Bash”,彈出一個類似命令列視窗,就說明Git安裝成功;
5.檢查本機是否有ssh key設定(SSH key提供了一種與GitHub通訊的方式,通過這種方式,能夠在不輸入密碼的情況下,將GitHub作為自己的remote端伺服器,進資料列版本設定):
$ cd ~/.ssh 或cd .ssh
如果沒有則提示: No such file or directory
如果有則進入~/.ssh路徑下(ls查看當前路徑檔案,rm * 刪除所有檔案)
6.如果沒有SSH key,則需要產生一個SSH key:
$ cd ~ #保證當前路徑在”~”下
$ ssh-keygen -t rsa -C "[email protected]" #[email protected]為你自己的郵箱路徑
建立ssh key之後提示如下
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxxx_000/.ssh/id_rsa): #不填直接斷行符號
Enter passphrase (empty for no passphrase): #輸入密碼(可以為空白,表示不要求輸入密碼,在輸入密碼過程中,密碼不可見,需要牢記自己的密碼)
Enter same passphrase again: #再次確認密碼(可以為空白)
Your identification has been saved in /c/Users/xxxx_000/.ssh/id_rsa. #產生的密鑰(產生的密鑰存放在c/Users/xxxx_000/下)
Your public key has been saved in /c/Users/xxxx_000/.ssh/id_rsa.pub. #產生的公開金鑰(同上)
The key fingerprint is:
e3:51:33:xx:xx:xx:xx:xxx:61:28:83:e2:81 [email protected]
7.添加ssh key 到github:
登陸github——>點擊頭像下拉框——>選中seething——>選擇SSH and GPG keys——>New SSH key——>添加標題title——>粘貼剛才產生的ssh key(在c/Users/xxxx_000/下用記事本開啟id_rsa.pub檔案,複製裡面內容)——>Add SSH key。
8.配置賬戶:
$ git config --global user.name “your_username” #設定使用者名稱
$ git config --global user.email “your_registered_github_Email” #設定郵箱地址(建議用註冊giuhub的郵箱)
9.測試ssh keys是否設定成功:
$ ssh -T [email protected]
The authenticity of host ‘github.com (192.30.252.129)‘ can‘t be established.
RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes #確認你是否繼續聯絡,輸入yes
Warning: Permanently added ‘github.com,192.30.252.129‘ (RSA) to the list of known hosts.
Enter passphrase for key ‘/c/Users/xxxx_000/.ssh/id_rsa‘: #產生ssh kye是密碼為空白則無此項,若設定有密碼則有此項且,輸入產生ssh key時設定的密碼即可。
Hi xxx! You‘ve successfully authenticated, but GitHub does not provide shell access. #出現詞句話,說明設定成功。
10.將項目通過SSH發布到github:
在github上建立一個樣本倉庫:
複製倉庫的ssh路徑:
建立本地項目:
1.建立目錄:
$ mkdir testdir (testdir檔案夾位於C:\Users\xxxx_000下)
$ cd testdir (進入到testdir目錄下,$ pwd顯示目前的目錄)
註:另外一種方法:在相應目錄直接建立檔案夾,右鍵開啟Git Bash Here
2.初始化:
$ git init
3.建立README.md檔案(.md 表示的是 MarkDown,是一種文字格式設定的檔案,通過添加一些符號讓文章的內容在排版上更有階層。)
$ echo "這是一次測試test ssh key" > README.md
註:在github建立倉庫時,往往會自動產生README.md檔案,可以直接匯入到本地:$ git pull ‘粘貼複製test ssh key的ssh路徑’
4.提交到本地:
$ git add . #提交目前的目錄下所以檔案
$ git commit -m "add hello.md" #提交記錄說明 ,add hello.md是對這次操作的描述
5.提交到github:
$ git remote add origin ‘粘貼複製test ssh key的ssh路徑’ #從倉庫複製下ssh路徑
$ git push -u origin master
Enter passphrase for key ‘/c/Users/hgpin_000/.ssh/id_rsa‘: #ssh key設定密碼故此需要輸入密碼
至此,就已經完成了本地項目的上傳,在github重新整理倉庫,新增內容被添加進去。
windows下使用github