How can I clone something on git with a different account?
For example, I might have been using one account for cloning, and now I need to access a repo that only a different account has access to.
Thanks for the help
How can I clone something on git with a different account?
For example, I might have been using one account for cloning, and now I need to access a repo that only a different account has access to.
Thanks for the help
If you clone via https you can do something like
git clone https://username@github.com/username/repository.git
This will prompt you for a password.
You can also directly provide a password by calling
git clone https://username:password@github.com/username/repository.git
But be aware that the password will be saved in .git/config and your bash history in that case which is not safe. If you don't like to enter the password every time you should consider cloning via ssh.
I tried above solution but it seems that support for password authentication was removed on August 13, 2021.
The solution is to use a personal access token which you can generate in Settings -> Developer Settings -> Personal access tokens.
After that:
git clone https://username:personal-access-token@github.com/username/repository.git
If this account's ssh-key has been added to your device, you can try this after ssh-add.
git clone git@<account_username>:<repo_username>/repository.git
Hope this could help.