Search code examples
bashazure-repos

Getting error "-bash: syntax error near unexpected token `(' " when cloning git repository


I am getting an error in my debian terminal when cloning a git repository.

Here is the command:

git clone git@ssh.dev.azure.com:v3/organization-example/RMC701%20(CBLPE00520)/Terraform-CB-connection-Vault

I am gettting this error:

-bash: syntax error near unexpected token `('

Is this because of the project name in Azure Devops ? RMC701%20(CBLPE00520)

I did not find any solution yet


Solution

  • Yes, the problem is caused by the project name, more precisely because of the parentheses "( )" in the project name. The parentheses "( )" could be recognized as a group of command lines if you do not pass them as part of a string.

    To avoid this issue, you need to use double or single quotes to surround the project name or the whole URL like as one of the command lines below:

    git clone git@ssh.dev.azure.com:v3/organization-example/'RMC701%20(CBLPE00520)'/Terraform-CB-connection-Vault
    

    or

    git clone git@ssh.dev.azure.com:v3/organization-example/"RMC701%20(CBLPE00520)"/Terraform-CB-connection-Vault
    

    or

    git clone 'git@ssh.dev.azure.com:v3/organization-example/RMC701%20(CBLPE00520)/Terraform-CB-connection-Vault'
    

    or

    git clone "git@ssh.dev.azure.com:v3/organization-example/RMC701%20(CBLPE00520)/Terraform-CB-connection-Vault"