一. 使用https提交方式:
1. 使用git config命令在本地全局設置用戶名和郵箱
git config --global user.name "username"
:全局添加用戶名
git config --global user.email “someone@mail.com”
:全局添加郵箱
git config --global credential.helper store
: 該命令用于為credential.helper設置值,避免重復輸入用戶名密碼
2. 執(zhí)行完成以上后,運行
cat ~/.gitconfig
會發(fā)現(xiàn).gitconfig多出了以下代碼
image.png
3. 再次git pull伶唯,只需輸入一次密碼筋岛,之后就可以不再輸入密碼了稚瘾。
image.png
二锦聊、使用ssh提交方式:
1. 生成秘鑰
執(zhí)行ssh-keygen
睡互。
如果原本沒有秘鑰,就一路回車嗽冒。如果有秘鑰且秘鑰關(guān)聯(lián)了其他網(wǎng)站的項目,比如gitlab什么的补履,那就需要重新指定目錄添坊。
2. 獲取公鑰
執(zhí)行 cat 你指定的目錄/id_rsa.pub
獲取公鑰(如果沒指定,就是 ~/.ssh/id_rsa.pub
)