2016.2.3
安裝gitbash
類linux命令行操作
打開bash
git config --global user.name "名字"
git config --global user.email"郵箱"
cd f:
cd git
git init
cd study
cd html5
git add readme.txt
fatal:pathspec 'readme.txt' did not match files
//原因,錯認爲add是創建,其實是將文件提交到暫存區
//此時我有疑惑,流程上,應該先驗證我是否又提交資格。
//於是我去在~/git/study/html5/ 下創建readme.txt
git commit -m"readme.txt提交"
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <Zeac@Zeac-PC.(none)>) not allowed
//此時需要我告訴他我的身份。而我此時以爲,我在網站上建的倉庫是公用的。
//所有人不需要持有我的密碼(未經我的允許即可提交),感到不合邏輯。
//但是之前已經輸入了郵箱和名字,爲什麼還這樣問?
//網上查之,需要ssh鏈接。
//首先是本地創建ssh key.
//這個東西類似於個人身份證(機器的)
$ ssh-keygen -t rsa -C"郵箱"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Zeac/.ssh/id_rsa):
Created directory '/c/Users/Zeac/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Zeac/.ssh/id_rsa.
Your public key has been saved in /c/Users/Zeac/.ssh/id_rsa.pub.
The key fingerprint is:
**********************************
The key's randomart image is:
+---[RSA 2048]----+
| ..+o o.++=|
| . +. + o o.|
| . o. . . .|
| o . o . . |
| o . + + .|
| .. = * . .|
| .oo + o.oE |
| .+o.o o.=.. |
| +*=o..+++ |
+----[SHA256]-----+
//會提示你將ssh的文件保存在什麼地方
//不太懂,一路回車
//最後創建完畢
ssh -T [email protected]
The authenticity of host 'github.com (2.22.22.222)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,22.22.22.222' (RSA) to the list of known hosts.
Permission denied (publickey).
//嘗試鏈接,失敗
//此時疑惑,我已經擁有ssh了,怎麼無法鏈接
//我的密碼怎麼沒有用到?
//網上查之,原來需要將ssh.pub裏面的字符串,複製到github裏面。
//此時明白,原來,當多人協同工作時,不是任何一個非組織之外的人都有權利修改
//需要和賬號擁有者協商(網上創建項目的人),然後將自己的ssh提供給賬號擁有者,在項目裏導入你的ssh(add deploy key),這樣你就有權利去提交項目。
git clone https://github.com/用戶名/項目名.git
Cloning into '項目名'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
//會發現當前目錄下有這個項目名 命名的文件夾,該文件夾下是你的項目文件。
//我的github項目目前是空的,所有我需要提交。
//新的文件目錄 ~/項目/study/html5/html5.html readme.txt
git add study
//提交到暫存區
git commit -m'解釋'
//提交到本地倉庫
git push -u origin master
//提交到網上倉庫
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 1.27 KiB | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To https://github.com/用戶名/項目名.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
-----------------------------------------------------------------------