網站首頁 編程語言 正文
一、背景:
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-10-01 sql語法中的concat()函數詳解_MsSql
- 2022-10-17 Nginx中root與alias區別講解_nginx
- 2022-07-06 ELK收集Nginx日志的項目實戰_nginx
- 2024-01-10 Springboot應用中@EntityScan和@EnableJpaRepositories的用法
- 2022-04-09 關于Python中的閉包詳解_python
- 2022-09-20 redis的string類型及bitmap介紹_Redis
- 2022-11-12 一文搞懂Go語言中defer關鍵字的使用_Golang
- 2022-09-22 uni ui 、color ui 圖標icon的使用
- 最近更新
-
- 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同步修改后的遠程分支