Use own username/password with git and bitbucket

后端 未结 7 1716
难免孤独
难免孤独 2020-12-07 13:08

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.

相关标签:
7条回答
  • 2020-12-07 13:43

    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://username@bitbucket.org/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.

    0 讨论(0)
  • 2020-12-07 13:47

    Well, it's part of BitBucket philosophy and workflow:

    • Repository may have only one user: owner
    • For ordinary accounts (end-user's) collaboration expect "fork-pull request" workflow

    i.e you can't (in usual case) commit into foreign repo under own credentials.

    You have two possible solutions:

    1. "Classic" BB-way: fork repo (get owned by you repository), make changes, send pull request to origin repo
    2. Create "Team", add user-accounts as members of team, make Team owner of repository - it this case for this "Shared central" repository every team memeber can push under own credentials - inspect thg repository and TortoiseHg Team, owner of this repository, as samples
    0 讨论(0)
  • 2020-12-07 13:50

    The prompt:

    Password for 'https://theirusername@bitbucket.org':
    

    suggests, that you are using https not ssh. SSH urls start with git@, for example:

    git@bitbucket.org:beginninggit/alias.git
    

    Even if you work alone, with a single repo that you own, the operation:

    git push
    

    will cause:

    Password for 'https://theirusername@bitbucket.org':
    

    if the remote origin starts with https.

    Check your remote with:

    git remote -v
    

    The remote depends on git clone. If you want to use ssh clone the repo using its ssh url, for example:

    git clone git@bitbucket.org:user/repo.git
    

    I suggest you to start with git push and git pull for your private repo.

    If that works, you have two joices suggested by Lazy Badger:

    • Pull requests
    • Team work
    0 讨论(0)
  • 2020-12-07 13:50

    For myself private repo, i use

    git@bitbucket.org:username/blog.git

    replace

    https://username@bitbucket.org/username/blog.git

    0 讨论(0)
  • 2020-12-07 13:58

    I had to merge some of those good answers here! This works for me:

    git remote set-url origin 'https://bitbucket.org/teamName/repo.git'
    

    In the end, it will always prompt anyone who wants to pull from it

    0 讨论(0)
  • 2020-12-07 14:01

    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>
    
    0 讨论(0)
提交回复
热议问题