使用自己的用户名/密码与git和bitbucket

boz*_*doz 56 git bitbucket

我是一个三人小组; 两个在本地工作,我正在服务器上工作.

我的同事设置了帐户,但给了我对存储库的完全权限.

我在git中设置了用户名和电子邮件:

git config --global user.name "bozdoz"
git config --global user.email email@email.com
Run Code Online (Sandbox Code Playgroud)

它们与我在bitbucket.org上的用户名和电子邮件相同.

但是,当我拉动或推送到存储库时,它会在提示符中指示其用户名:

Password for 'https://theirusername@bitbucket.org':
Run Code Online (Sandbox Code Playgroud)

我尝试通过用我的用户名指示URL来获取密码提示:

git pull https://bozdoz@bitbucket.org/path/repo.git
Run Code Online (Sandbox Code Playgroud)

它说是最新的; 然后当我推动时,它说没有快进.

我读到我需要指定分支,但是当我还指定repo URL时,我不知道如何在push语句中执行此操作:

git push https://bozdoz@bitbucket.org/path/repo.git
Run Code Online (Sandbox Code Playgroud)

如果我的同事在附近并且可以输入他的密码,我能够拉动和推动.但这也是他作为推动的作者,而不是我.

我如何作为自己的用户名拉动并推送到repo分支?

Eri*_*jst 74

git remote -v
Run Code Online (Sandbox Code Playgroud)

并检查您的来源的URL是否在那里硬编码了您的同事的用户名.如果是这样,请用您自己的替换:

git remote set-url origin <url-with-your-username>
Run Code Online (Sandbox Code Playgroud)

  • 棒极了。非常感谢。完美地工作。StackOverflow 的新手?如果你想拥有一些声誉,我想给你一些声誉。我可以在 2 天内奖励赏金。 (2认同)

boz*_*doz 61

我想我应该分享我的解决方案,因为我无法在任何地方找到它,只能通过反复试验来解决.

我确实能够将存储库的所有权转移到BitBucket的团队.

不要添加BitBuckets建议的远程URL:

git remote add origin https://username@bitbucket.org/teamName/repo.git
Run Code Online (Sandbox Code Playgroud)

而是在没有用户名的情况下添加远程URL:

git remote add origin https://bitbucket.org/teamName/repo.git
Run Code Online (Sandbox Code Playgroud)

这样,当您从拉出或推送到回购时,它会提示您输入用户名,然后提示您输入密码:团队中的每个人都可以使用自己的凭据访问它.这种方法仅适用于BitBucket上的团队,即使您可以管理单一所有者回购的用户权限.


Wło*_*jda 12

提示:

Password for 'https://theirusername@bitbucket.org':
Run Code Online (Sandbox Code Playgroud)

建议你使用https而不是ssh.SSH网址以git @开头,例如:

git@bitbucket.org:beginninggit/alias.git
Run Code Online (Sandbox Code Playgroud)

即使您单独工作,使用您拥有的单个仓库,操作:

git push
Run Code Online (Sandbox Code Playgroud)

会引发:

Password for 'https://theirusername@bitbucket.org':
Run Code Online (Sandbox Code Playgroud)

如果远程原点以https.

检查您的遥控器:

git remote -v
Run Code Online (Sandbox Code Playgroud)

遥控器取决于git clone.如果你想使用ssh url使用ssh clone repo,例如:

git clone git@bitbucket.org:user/repo.git
Run Code Online (Sandbox Code Playgroud)

我建议你开始git pushgit pull你的私人回购协议.

如果可行,你有两个由Lazy Badger建议的联系:

  • 拉请求
  • 团队合作