簡體   English   中英

如何在bash中執行git clone時自動獲取密碼

[英]How to automatically get the password while doing git clone in bash

我的bash腳本是:

#!/bin/bash
git clone https://abc@xyz.com/xxx/xxxx/pqr.git
git clone https://abc@xyz.com/xxx/xxxx/pqr2.git
git clone https://abc@xyz.com/xxx/xxxx/pqr3.git
git clone https://abc@xyz.com/xxx/xxxx/pqr4.git

現在它每次都要求我輸入密碼,即4次。。。我必須輸入密碼4次。即每次執行git clone。 我想將密碼存儲在變量“ passwd”中,並使用它來輸入“ Enter password”語句。 基本上需要使其自動化

一個簡單的解決方案是git憑證。 只需將超時設置為足夠大的值即可克隆這些存儲庫:

git config --global credential.helper 'cache --timeout=3600' # 1 hour

但如果你真的想這樣做,您所描述的方式,然后監視與命令的輸出與發送密碼exp_send "passwd\\r"Enter password遇到。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM