網站首頁 編程語言 正文
一、背景:
git clone代碼或者push代碼時候需要輸入賬號密碼
二、解決方法:
1、ssh方式:
先用git config --global user.name 'username’和git config --global user.email 'xxx@xxx.com’配置一下用戶名和郵箱
生成ssh公鑰:ssh-keygen -t rsa -C “xxxxx@xxxxx.com”,查看~/.ssh/id_rsa.pub文件內容,獲取到你的public key,粘貼到GitLabssh公鑰管理處即可
使用git clone http://git.gitxxx.com/xxx.git,先測試一下,看能不能拉取成功。如果成功,向下進行。此時還是會詢問用戶名和密碼的。
2、免密拉取配置
(1)cd到~/目錄下,創建一個文件:touch .git-credentials
vim .git-credentials
(2)然后輸入https://{username}:{password}@git.gitxx.com,比如http://fengjiaheng:password@git.gitxx.com
(3)然后執行:git config --global credential.helper store
(4)然后使用git config --list或者查看一下~/.gitconfig文件,會發現多了一行[credential] helper = store
(5)這時候再用 git 拉取倉庫就不需要輸入用戶名和密碼了。
注意:第4步必須要做,否則做完4、5步之后也不能免密碼拉取成功,需要再次執行第4步驟。
3、粗暴使用型
Git Clone命令直接使用用戶名密碼Clone
git clone http://userName:password@鏈接
修改為 git clone https://username:password@鏈接
示例:
git clone git@http://112.12.122.22:t-mapi/hotel-tapi.git
修改為
git clone ‘http://username:password@112.12.122.22:t-mapi/hotel-tapi.git’
注意:
(1)http -> https
(2)如果賬號username或者password中有@符號,需要 將@替換為%40
(3)如果報錯git clone event not found,需要將 git clone 后地址加上引號 ‘’
三、總結:
1、第二種方法比較簡單(推薦使用),但是第一二種方法中都首次都必須自己輸入賬號密碼
2、第三種一次都不用輸入賬號密碼(推薦使用)
原文鏈接:https://blog.csdn.net/weixin_39676449/article/details/126122939
相關推薦
- 2022-08-30 詳解Oracle控制文件及日志文件的管理問題_oracle
- 2022-07-10 oracle中的session
- 2022-06-29 Oracle中的分析函數匯總_oracle
- 2022-12-24 Docker網絡及容器通信原理詳解_docker
- 2022-01-15 Meteor 項目部署至服務器(windows)
- 2022-06-16 python遺傳算法之單/多目標規劃問題_python
- 2022-09-16 go數據結構和算法BitMap原理及實現示例_Golang
- 2022-08-19 python項目中requirements.txt的用法實例教程_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支