添加遠程庫:git
1.關聯一個遠程庫:github
git remote add origin git@server-name:path/repo-name.git;shell
例:git remote add origin git@github.com:gz@163.com/learngit.gitbash
2.第一次推送master分子的全部內容:ssh
git push -u origin masteride
3.每次本地提交後,就能夠使用:測試
git push origin master 推送新版本。server
從遠程庫克隆:rem
1.第一種方法:git clone https://github.com/123/456.git (此地址是項目生成的遠程地址)get
2.第二種方法:
1)在要克隆項目的本地目錄下,啓動git bash
2)輸入ssh-keygen回車,記住生成的括號中的路徑。
3)繼續輸入3個回車,完成key建立,最後獲得連個文件:id_rsa和id_rsa.pub;
4)github添加SSH keys,將id_rsa.pub裏面的內容複製下來,在github上的settings裏面找到 SSH and GPG keys,將其粘貼到key便可,title惟一便可隨便填,建議寫有意義的;
5)在Git Bash控制檯測試一下,輸入:ssh -T git@github.com
只要看到最後一行Hi wqcreed! You've successfully authenticated, but GitHub does not provide shell access.
說明驗證成功了
1)建立一個新的git庫
2)根據你的項目需求填寫相應內容
3)點擊「Clone or download」,複製:git@github.com:wqcreed/Test.git,後面有用
1)找個本身工做目錄下,空白處右鍵選擇「Git Bash Here」;
輸入命令: git clone git@github.com:wqcreed/Test.git
能看到後面就是剛纔複製的SSH地址,看到以下圖所示,就能夠到本身工做目錄下看到庫文件克隆到本地了
2)上傳添加文件到倉庫,依次輸入如下命令;
git add . 這個點不要忘了
git commit -m "test log" 上傳日子
git push origin master 推送到GitHub倉庫:
第二種方法參考地址:https://www.jianshu.com/p/17d0797c42d7
(親測可行)