While the previous replies offered various solutions, I found that the easiest one of them is to add the username to the repository's URL
git remote add origin https://[email protected]/your-username/repository-name.git
In case you have already defined the repository (without adding the username) you can update it as follows,
git remote set-url origin https://[email protected]/your-username/respository-name.git
When pushing to the remote repository git won't pull the credential of any other existing repository from the credential helper, but will ask for the user's/repository's specific password defined in the URL.
As a general note, I'd avoid to use your account's password at all cost and use a personal access token instead. Log in to github and select,
Settings > Developer Settings > Personal Access Tokens > Generate new token
Just make sure to check repo when defining the token's scope and enter the token (instead of your personal password) when asked for a password.
git push -f
, but works with a regular push, pull and fetch? – CallahanSettings -> Developer settings -> Personal access tokens
and confirmwrite.packages
is checked. This was my problem. – Bluestonegh auth login
– DarondaroogeSettings -> Developer settings -> Personal access tokens
and confirmrepo (Full control of private repositories)
– Panditgit remote set-url origin https://[email protected]/your-repo.git
– Onto