Home > Blockchain >  How to provide a `git clone` with a username
How to provide a `git clone` with a username

Time:02-01

I'm trying to clone a repo, lets say that the url is example.com/my-code and my username is john@foo. Now, the problem is, when I do

$> git clone example.com/my-code
 [email protected]'s password: 

which is is an incorrect username!

I tried to provide the username in the url

$> git clone john@[email protected]/my-code
john@[email protected]'s password:

Even when I use -v it ask me for a password directly. So, my question is, how can I provide it a different username? Via the url is find, but I prefer the CLI. thnx

CodePudding user response:

TL;DR

You'll want to set up your ssh configuration. See below.

Long

URL (or more properly, URI) syntax in general is:

<scheme>:[//<authority>]<path>[?query][#fragment]

as described more properly Clone code URL via SSH

Make sure to add your public key to your profile settings!
If you are talking about username/email, read below as well.

Configure user and email globally

To configure your user and/or email adress globally, use this:

$ git config --global user.name "Example Name"
$ git config --global user.email "[email protected]"

Configure user and email once

To have a certain user and/or email adress you can change the configuration for one call only:

$ git -c user.name="Example Name" -c user.email="[email protected]"
  •  Tags:  
  • Related