Amelia
Amelia

Reputation: 33

Git asks password for wrong username whenever I git pull or push

I have a repo - let's say it's remote address is https://[email protected]/myself/my-repo.git. I am sharing this repo with my colleague - I have granted him admin access to this repo to his account. Let's say his bitbucket account is https://[email protected]. He clones the repo. But whenever he tries to push/pull the repo, git asks for the password for my account (https://[email protected]) not his account (https://[email protected]). How do I change git settings so that git asks for his account (https://[email protected]) instead of mine?

Thanks in advance!

Upvotes: 0

Views: 1330

Answers (2)

Code-Apprentice
Code-Apprentice

Reputation: 83527

First, you can view the URL used for the BitBucket repo by typing

git remote -v

This most likely will show that your colleague cloned has a remote that specifies your user name. The easiest way to fix this is to remove the user name from the url:

git remote set-url origin https://bitbucket.org/myself/my-repo.git

Now when they push/pull/fetch/etc, git will ask for both a user name and a url.

If your colleague doesn't want to type the user name each time, then they can instead do

git remote set-url origin https://[email protected]/myself/my-repo.git

If you are annoyed by always typing a username and password, I suggest setting up an SSH key and uploading the public key to BitBucket. The BitBucket docs explain how to do this. SSH is very convenient and provides secure access to your accounts.

Upvotes: 3

Chris Dodd
Chris Dodd

Reputation: 126203

He needs to use the URL https://[email protected]/myself/my-repo.git to clone the repo -- note it has his username in one place and yours in another.

Upvotes: 0

Related Questions