My current command is
git clone ssh://[email protected]/srv/git/repo
after that
password
... fine, works good.
Now I would like do this in one line. Something like that:
git clone ssh://username:[email protected]/srv/git/repo
but it`s not working and gives me the message:
Please make sure you have the correct access rights and the repository exists.
How can I clone in a single line?
If you want to clone it to a specific folder, just insert the folder address at the end like so: git clone https://<token>@github.com/<username>/<repository.git> <folder> , where <folder> is, you guessed it, the folder to clone it to! You can of course use . , .. , ~ , etc.
In order to clone a git repository into a specific folder, execute the “git clone” command and specify the destination folder at the end. $ git clone https://github.com/username/project.git myproject Cloning into 'myproject'... remote: Enumerating objects: 813, done.
As we had mentioned earlier on, when cloning a remote Git repository over HTTP(S), every connection needs a username and password as shown.
You should be able to use the http
url instead to clone it:
git clone http://username:[email protected]/srv/git/repo.git
Edit:
If in case you can do this by normal ssh only with username-password credentials, try using sshpass
like:
sshpass -p password git clone ssh://[email protected]/srv/git/repo
You might have to install sshpass
for this.
Note that this is the case when the ssh keys are not correctly configured; if the ssh keys were configured, your public key would be shared with the target server and you wouldn't have needed to enter the password (you might have had to enter a passphrase though).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With