How do I provide a username and password when running "git clone [email protected]"?


I know how to include a username and password in a https Git URL like this:

git clone https://username:password@host

But I'd like to know how to provide a username and password to an SSH remote like this:

git clone [email protected]

I've tried like this:

git clone username:password@[email protected]
git clone git@username:[email protected]
git clone [email protected]@username:password

But they haven't worked.


Based on Michael Scharf's comment:

You can leave out the password so that it won't be logged in your Bash history file:

git clone https://[email protected]/username/repository.git

It will prompt you for your password.

Alternatively, you may use:

git clone https://username:[email protected]/username/repository.git

This way worked for me from a GitHub repository.

fatal: Not a git repository (or any of the parent directories): .git [duplicate]

Is it possible to have different Git configuration for different projects?