How can I git clone from powershell without typing credentials?

14,033

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

Share:
14,033
monkzen
Author by

monkzen

Updated on June 06, 2022

Comments

  • monkzen
    monkzen almost 2 years

    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