1. 程式人生 > 其它 >|NO.Z.00005|——————————|^^ 配置 ^^|——|CI/CD&Git配置.V04|---------------------------------------------------------|SSH連線|

|NO.Z.00005|——————————|^^ 配置 ^^|——|CI/CD&Git配置.V04|---------------------------------------------------------|SSH連線|



[CloudNative:CI/CD&Git配置.V04]                                                                          [Applications.CloudNative] [|CI/CD|分散式版本控制系統|**3節點**|Jenkins|Git|——|git.server|git.client|ssh|] [Git架構圖|GIt概念|Git專案互動|Git常用命令|http|Git解決衝突|]








一、SSH連線
### --- SSH連線

~~~     客戶機上產生公鑰上傳到gitlab的SSH-Keys裡,
~~~     git clone下載和git push上傳都沒問題,這種方式很安全
二、http 連結(兩種方式實現)
### --- 配置http連線
~~~     檢視git.http配置資訊

[root@server12 ~]# cd .git
[root@server12 ~]# cat config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = http://username:[email protected]@172.17.0.39:sauser/ansible.git
[branch "master"]
remote = origin
merge = refs/heads/master
三、登入Git賬戶
### --- cd到根目錄,執行
~~~     執行之後會在.gitconfig檔案中多新增以下選項
                 
[root@server12 ~]# git config --global credential.helper store 
  [credential]        
          helper = store
### --- cd到專案目錄,執行git pull命令,會提示輸入賬號密碼。
~~~     輸完這一次以後就不再需要,並且會在根目錄生成一個.git-credentials檔案

[root@server12 ~]# git pull
  Username for 'http://172.17.0.39:sauser/ansible.git':
  [email protected] Password for 'https://[email protected]@172.17.0.39:sauser/ansible.git':
### --- 之後pull/push程式碼都不再需要輸入賬號密碼了

[root@server12 ~]# cat .git-credentials
  https://Username:[email protected]
四、設定身份驗證
### --- 設定身份驗證
~~~     **注意:**設定本機使用者名稱,繫結郵箱,讓遠端伺服器知道機器的身份

[root@server12 ~]# git config --global user.name "user_name"
[root@server12 ~]# git config --global user.email "[email protected]"








===============================END===============================


Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart                                                                                                                                                    ——W.S.Landor



來自為知筆記(Wiz)