I know how to provide a username and password to an HTTPS request like this:
git clone https://username:password@remote
But I\'d like to kn
In the comments of @Bassetassen's answer, @plosco mentioned that you can use git clone https://
to clone from GitHub at the very least. I thought I would expand on how to do that, in case anyone comes across this answer like I did while trying to automate some cloning.
GitHub has a very handy guide on how to do this, but it doesn't cover what to do if you want to include it all in one line for automation purposes. It warns that adding the token to the clone URL will store it in plaintext in .git/config
. This is obviously a security risk for almost every use case, but since I plan on deleting the repo and revoking the token when I'm done, I don't care.
GitHub has a whole guide here on how to get a token, but here's the TL;DR.
Same as the command @plosco gave, git clone https://
, just replace
,
and
with whatever your info is.
If you want to clone it to a specific folder, just insert the folder address at the end like so: git clone https://
, where
is, you guessed it, the folder to clone it to! You can of course use .
, ..
, ~
, etc. here like you can elsewhere.
Not all of this may be necessary, depending on how sensitive what you're doing is.
rm -rf
.git remote remove origin
or just remove the token by running git remote set-url origin https://github.com//
.Note that I'm no pro, so the above may not be secure in the sense that no trace would be left for any sort of forensic work.