Github(2)-本地配置git
本地配置git
- 1.注冊賬號
- 2.安裝git工具
- 3.配置git 賬號
1.注冊賬號
github網頁注冊github賬戶
2.安裝git工具
本地安裝git工具
step1 查看是否安裝git
git version
step2 mac 安裝
brew install git
step2 linux安裝
sudo apt-get install git
3.配置git 賬號
創建ssh key, 配置本地git與github服務器上的對應賬號連接
step1 設置連接賬號和郵箱
git config --global user.name “cyy-hub”
git config --global user.email “xxx@xx.com”
global參數,表示你這個用戶下所有的Git倉庫都會使用這個配置,當然也可以對某個倉庫指定不同的用戶名和E-mail地址(去除global參數)。如果使用system參數,那么這個機器上所有用戶都將使用這個配置。
配置賬號作用域參考文獻–https://www.daixiaorui.com/read/240.html
step2 配置賬號公鑰,會在~/.ssh 中生成密鑰文件id_rsa_cyy_hub.pub
ssh-keygen -t rsa -f ~/.ssh/id_rsa_cyy_hub # (-f 指定生成的密鑰所在的文件)
輸出
Enter passphrase (empty for no passphrase):
Enter same passphrase again: #(這個密碼之后在連接倉庫的時候會用到,直接按enter默認不需要密碼)
Your identification has been saved in ~/.ssh/id_rsa_cyy_hub.
Your public key has been saved in ~/.ssh/id_rsa_cyy_hub.pub.
step3 復制公鑰內容到github平臺 setting->SSh and GPG key
cat ~/.ssh/id_rsa_cyy_hub.pub
# 復制輸出內容
step4 修改 ssh config內容
vim ~/.ssh/config
Host github-hub
HostName github.com
IdentityFile ~/.ssh/id_rsa_cyy_hub
User cyy-hub
step5 查看是否能成功連接,輸出hi就成功了(Host 與HostName 一致 )
ssh git@github.com
Hi cyy-hub! You’ve successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
如果 step4 中設置Host別名,可以直接使用ssh 別名訪問
ssh github-hub
(遺留問題)使用了別名之后git clone git@github.com:cyy-hub/cyy-job-note.git 無法成功,改Host Hostname一致就可以了。
stpe6 多賬戶配置
http://www.fly63.com/article/detial/1124 (主要看這一篇)
https://www.jianshu.com/p/b6bd61e1bc5f
https://www.cnblogs.com/yanbinliu/p/4095433.html
查看git配置
git config -l
參考博文:https://www.cnblogs.com/fireporsche/p/9359130.html
(遺留問題)如何配置一個倉庫級別的用戶呢?
以下列出兩個可供學習遠程操作的博客網址:
1.ubuntu安裝和使用git總結:git命令總結很整齊:
https://blog.csdn.net/m0_37950361/article/details/80138929
2.Ubuntu下git的安裝與使用:ssh Key 創建講解詳細,但是庫里添加秘鑰時,建議看上一個博客:https://www.cnblogs.com/lxm20145215----/p/5905765.html
總結
以上是生活随笔為你收集整理的Github(2)-本地配置git的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Pytorch(4)-模型保存-载入-e
- 下一篇: Shiro学习笔记