ubuntu+github配置使用

2015年末開始學習Python,接觸了git這個東西,會基礎的使用,順便在github上註冊了帳號 https://github.com/haoxrgit

今天從新整理一下配置使用的整個流程github

 

1 github註冊帳號shell

 

本地安裝git

 

2 本地安裝gitdom

sudo apt-get update  
sudo apt-get install git

git官網下載地址:https://git-scm.com/downloadsssh

 

3 初始化目錄 在須要git的目錄下打開終端ide

git init  

這樣就在本地創建了git倉庫。能夠直接操做git其餘命令。學習

在創建本地庫與github關聯以前,咱們須要作一些配置工做fetch

 

SSH配置

 

4 建立SSH Keyurl

參考廖雪峯的: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001374385852170d9c7adf13c30429b9660d0eb689dd43a000spa

在用戶主目錄下,看看有沒有.ssh目錄,若是有,再看看這個目錄下有沒有id_rsaid_rsa.pub這兩個文件,若是已經有了,可直接跳到下一步。

若是沒有,打開Shell(Windows下打開Git Bash),建立SSH Key:郵箱地址爲github郵箱地址

ssh-keygen -t rsa -C "youremail@example.com"

把id_rsa.pub內容添加到github的SSH keys頁面。

 

5 驗證是否鏈接成功

ssh -T git@github.com

成功結果爲:

Hi haoxr! You've successfully authenticated, but GitHub does not provide shell access.

若是出現 Permission denied (publickey). 錯誤,參考:https://help.github.com/articles/error-permission-denied-publickey/

eval "$(ssh-agent -s)"
ssh-add

 

SSH警告

第一次使用Git的clone或者push命令鏈接GitHub時,會獲得一個警告,輸入yes回車便可。

The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is xx.xx.xx.xx.xx.
Are you sure you want to continue connecting (yes/no)?

 

 

創建本地庫與github關聯

 

6 本地配置github

git config --global user.name "Your Name"  
git config --global user.email "youremail@domain.com"  

查看配置信息

git config --list 

 

7 本地庫與github關聯

git remote add origin git@github.com:haoxr/-faceDetection.git
git@github.com:haoxr/-faceDetection.git 能夠在你項目中去複製

 

關聯後能夠在.git目錄下的config文件中查看結果:

[remote "origin"]
    url = git@github.com:haoxr/-faceDetection.git
    fetch = +refs/heads/*:refs/remotes/origin/*

可能會出現 the repository exists. 提示,表示你重複關聯了,若是須要重置,能夠直接在以上文件中刪掉,也能夠命令:

git remote rm origin

再從新關聯

 

提交到github

 

8 添加全部文件

git add .

9 提交到本地庫

git commit -m 提交內容說明

10 提交到遠程庫

git push -u origin master

第一次推送master分支時,加上了-u參數,Git不但會把本地的master分支內容推送的遠程新的master分支,還會把本地的master分支和遠程的master分支關聯起來,

在之後的推送或者拉取時就能夠簡化命令,只要本地做了提交,就能夠經過命令把本地master分支的最新修改推送至GitHub

git push origin master

提交的文件有大小限制,注意大文件的移除和備份。

 

github的分支以及不少操做就不說了,須要用到的網上搜便可。 

相關文章
相關標籤/搜索