【GitHub】 初學Git,Github在Ubuntu下的配置
1.參考連結:https://blog.csdn.net/tina_ttl/article/details/51326684
http://www.runoob.com/w3cnote/git-guide.html
開始使用github
1. 配置git
git config --global user.name "你的github使用者名稱"
git config --global user.email "你的github郵箱地址"
然後 Shell執行
cd ~/.ssh
ssh-keygen -t rsa -C "你自己的github對應的郵箱地址"
將剛剛建立的ssh keys新增到github中
(1)利用gedit/cat命令,檢視並複製id_rsa.pub所有的內容
(2)在GitHub中,依次點選Settings -> SSH Keys -> Add SSH Key,將id_rsa.pub檔案中的字串複製進去,注意字串中沒有換行和空格,儲存。
輸入如下命令:
ssh -T [email protected]
如果看到如下所示,則表示新增成功:
You’ve successfully authenticated, but GitHub does not provide shell access.
2. 新建本地資料夾(倉庫)
本地倉庫初始化
3. 在Github.com新建一個倉庫(repository),例如: https://github.com/XiaoGongWei/Ubuntu16.04-Code.gitcd ~/Document/newflode git init touch Readme.me
進入要上傳的倉庫,右鍵git bash,新增遠端地址:
注:https://github.com/你的github使用者名稱/你的github倉庫.git 是github上倉庫的網址
4. 將檔案增加到本地快取 index
git add Readme.me
(git add <filename> 或 git add *)
git commit -m 'add readme file'
5. push 推送本地倉庫到網路
你的改動現在已經在本地倉庫的 HEAD 中了。執行如下命令以將這些改動提交到遠端倉庫:
git push origin master
可以把 master 換成你想要推送的任何分支。
6. 提交更改
返回到根目錄下面
git add *
git commit -m 'add some files'
git push origin master
無密碼登入:
vim .git-credentials
https://{username}:{password}@github.com
進入git bash終端, 輸入如下命令:
git config --global credential.helper store
執行完後檢視%HOME%目錄下的.gitconfig檔案,會多了一項:
[credential]
helper = store
重新開啟git bash會發現git push時不用再輸入使用者名稱和密碼
7. 更多內容請看下面連結
無密碼登入:http://www.cnblogs.com/ballwql/p/3462104.html
http://www.runoob.com/w3cnote/git-guide.html