Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I git clone from powershell without typing credentials?

What I am trying to do is to create one of the steps in CI pipeline that is responsible for git operations. Let say external user provides git URL, username and password. I'd like to have something like that:

function Get-GitClone{
   param([string]$URL,
         [string]$username,
         [string]$password
   )

   # Create temp folder
   cd C:\Temp
   mkdir GitTemp

   # Clone TFD Git repository
   git clone $URL
}

What I'm getting is error running this script, simply because is you run this from powershell it will ask for credentials. I have tried git-credential-winstore.exe, but it still needs user interaction Google doesn't help either or I just can't find anything useful.

Thanks in advance

like image 844
monkzen Avatar asked Apr 25 '26 13:04

monkzen


1 Answers

Have you tried $username:$password@$URL?

like image 81
Rodrigo Nonose Avatar answered Apr 28 '26 02:04

Rodrigo Nonose



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!