'git clone with different username/account
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
Solution 1:[1]
If you clone via https you can do something like
git clone https://[email protected]/username/repository.git
This will prompt you for a password.
You can also directly provide a password by calling
git clone https://username:[email protected]/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.
Solution 2:[2]
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:[email protected]/username/repository.git
Solution 3:[3]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Juani D'Ambrosio |
Solution 3 | Venus |