github上傳與下載,github上傳下載
1、建立SSH key
第一次使用github,首先在本地建立ssh key
ssh-keygen -t rsa -C "your_email@youremail.com"
後面的your_email@youremail.com改為你的郵箱,之後會要求確認路徑和輸入密碼,我們這使用預設的一路斷行符號就行。
成功的話會在~/下產生.ssh檔案夾,進去,開啟id_rsa.pub,複製裡面的key。
回到github,進入Account Settings,左邊選擇SSH Keys,Add SSH Key,title隨便填,粘貼key。類似於:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA63rye64sOsj3wINkbDKcnEC78bG/Bg0DBS5Q6TZaEglIHTAhszWu/meFuUiUHGpKSzVc29DHeqaM7Jvad3zhcaceu5Bl1OFT7devC0Q3s5k+MYwdIwc/OiiF9MBia5iXxS6N2i7NSEoXjFiS2EcpXPmhn/pljxCIzOhJy2OB3i6VBJJBFYb2BL03/ozOqnI3hKk3o8hpop28UkzKr4f+ObPZDAyI9riXhbu5nnZDqQSzlwv3NDoZOOWm9t8NcEUIeMSSB5+FGY64CPGE85GUop1+2QcVpRBMd2CU3R4NtFllFYwnf9f3uGoXG6IBPBP2EO3KBGXaHj0v83rpqbt+2w== cdkd321@126.com
為了驗證是否成功,在git bash下輸入:
ssh -T git@github.com
如果是第一次的會提示是否continue,輸入yes就會看到:
You’ve successfully authenticated, but GitHub doesnot provide shell access
這就表示已成功連上github。
上傳
//or create a new repository on the command lineecho # command >> README.mdgit initgit add README.mdgit commit -m "first commit"git remote add origin git@github.com:xiabodan/command.gitgit push -u origin master
//or push an existing repository from the command linegit remote add origin git@github.com:xiabodan/command.gitgit push -u origin master
下載
第一次下載
git clone https://github.com/xiabodan/DataStructure.git
更新代碼
git pull