What specific syntax needs to be changed in the windows command line commands below in order for git remote add origin %repoWithToken% to resolve to the intended valid URL?
COMMANDS THAT ARE FAILING:
The following commands are run in a pwsh shell on a windows-latest GitHub runner.
set repoWithToken="https://"$GIT_PAT"@github.com/accountName/repoName.git"
git init
git remote add origin %repoWithToken%
ERROR MESSAGE:
The following error message is given by the GitHub windows-latest runner when the above code is run:
fatal: '%repoWithToken%' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Error: Process completed with exit code 1.
The answer can just be simple windows command line command. No need for any fancy PowerShell.
Also, $GIT_PAT is correct GitHub syntax, though it is possible that the concatenation in set repoWithToken="https://"$GIT_PAT"@github.com/accountName/repoName.git" might need to be done differently in the code above. This is in the process of being translated from Bash.
setis an alias forSet-Variable. Is there a special reason why you're not using the native PowerShell cmdlets? If you want to use a variable in PowerShell it will not work with%repoWithToken%. You have to use$repoWithToken. And you can create the variable like this:$repoWithToken = "https://$($GIT_PAT)@github.com/accountName/repoName.git"$GIT_PATvariable works in bash, but$GIT_PATis a GitHub variable, so I am not sure if%$GIT_PAT%would work.$GIT_PATliterally you can assign the variable in PowerShell like this:$repoWithToken = 'https://[email protected]/accountName/repoName.git'( enclosed in single quotes ). And you can use it like this:git remote add origin $repoWithToken