Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use own username/password with git and bitbucket

Tags:

git

bitbucket

I'm in a team of three; two are working locally, and I am working on the server.

My coworker set up the account, but gave me full privileges to the repository.

I set my username and email in git:

git config --global user.name "bozdoz" git config --global user.email [email protected] 

and they are identical to my username and email on bitbucket.org.

But when I pull or push to the repository it indicates their username in the prompt:

Password for 'https://[email protected]': 

I was able to get a prompt for my password after trying to pull by indicating the URL with my username:

git pull https://[email protected]/path/repo.git 

and it said up-to-date; and then when I pushed, it said no-fast-forward.

I read that I need to specify the branch, but I don't know how to do that in a push statement while I'm also specifying the repo URL:

git push https://[email protected]/path/repo.git 

I am able to pull and push if my co-worker is around and can put his password in. But this is also listing him as the author of the push, and not me.

How can I pull and push to a repo branch as my own username?

like image 729
bozdoz Avatar asked Mar 01 '13 20:03

bozdoz


People also ask

How do I use Bitbucket App password in git?

The first time you clone a repository you are prompted to provide your Bitbucket username and password. Provide your account name as the username, and type the Bitbucket App password into the password field. After the authentication completes, the git clone operation proceeds.


2 Answers

Run

git remote -v 

and check whether your origin's URL has your co-worker's username hardcoded in there. If so, substitute it with your own:

git remote set-url origin <url-with-your-username> 
like image 137
Erik van Zijst Avatar answered Sep 25 '22 10:09

Erik van Zijst


I figured I should share my solution, since I wasn't able to find it anywhere, and only figured it out through trial and error.

I indeed was able to transfer ownership of the repository to a team on BitBucket.

Don't add the remote URL that BitBuckets suggests:

git remote add origin https://[email protected]/teamName/repo.git 

Instead, add the remote URL without your username:

git remote add origin https://bitbucket.org/teamName/repo.git 

This way, when you go to pull from or push to a repo, it prompts you for your username, then for your password: everyone on the team has access to it under their own credentials. This approach only works with teams on BitBucket, even though you can manage user permissions on single-owner repos.

like image 27
bozdoz Avatar answered Sep 21 '22 10:09

bozdoz