Bitbucket git push 作为用户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15166932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:38:29  来源:igfitidea点击:

Bitbucket git push as user

gitbitbucket

提问by diego2k

1) I create a new repo on bitbucket using the main TEAM user.

1) 我使用主 TEAM 用户在 bitbucket 上创建了一个新的存储库。

2) Then i add all development keys that will be able to download this repo.

2) 然后我添加所有能够下载这个 repo 的开发密钥。

3) Went to a server and made a clone of this repo using the command:

3) 前往服务器并使用以下命令克隆此 repo:

git clone ssh://[email protected]/user/repo.git

4) I made some changes to the code and made the commit

4)我对代码进行了一些更改并进行了提交

git commit -a -m "some improves"

So here's the Question:

所以这里的问题是:

I can't do a git push bec i don't have push right to do that with this user:

我不能执行 git push 因为我没有权利对这个用户这样做:

# git push
conq: repository access denied. access via a deployment key is read-only.
fatal: The remote end hung up unexpectedly

So, how can i make a push using my username/password?

那么,我如何使用我的用户名/密码进行推送?

回答by Marcus

You could always setup a second remote on your server using https:

您始终可以使用 https 在您的服务器上设置第二个遥控器:

git remote add edit-only-origin https://bitbucket.org/user/repo.git

Then, you could make small edits, commit and then use the command

然后,您可以进行小的编辑,提交,然后使用命令

git push edit-only-origin

This would prompt you for both your username and password.

这将提示您输入用户名和密码。

回答by yeesterbunny

From my understanding, deployment keyis for read-only access. To be able to push, you need to add your computer's sshkey.

根据我的理解,deployment key是只读访问。为了能够推送,您需要添加计算机的ssh密钥。

Go to Manage Account, and on the left, choose SSH keys. Add key by copy and pasting your rsa.pub public key.

转到管理帐户,然后在左侧选择 SSH 密钥。通过复制和粘贴您的 rsa.pub 公钥来添加密钥。

It's better if you copy it from terminal to make sure no funky characters get in the mix. To do so in OSX, type pbcopy < ~/.ssh/id_rsa.pub. For Linux, look at Agush's comment.

如果您从终端复制它以确保混合中没有时髦的字符会更好。要在 OSX 中执行此操作,请键入pbcopy < ~/.ssh/id_rsa.pub. 对于 Linux,请查看 Agush 的评论。

回答by user4493000

Looks like you did use developer's key. Need to add SSH-key in the profile and remove them in the repository-section.

看起来您确实使用了开发人员的密钥。需要在配置文件中添加 SSH 密钥并在存储库部分中删除它们。

回答by s29

Try using HTTPS instead of SSH --

尝试使用 HTTPS 而不是 SSH --

git -c user.email='[email protected]' -c user.name='myusername' commit
git push https://[email protected]/path-to/myrepos.git master

SSH uses the key, which in this case only gets you read access. HTTPS will prompt for your password, giving you write access to push.

SSH 使用密钥,在这种情况下,它只会让您获得读取权限。HTTPS 将提示您输入密码,为您提供推送的写访问权限。

Handy for quick edits on servers that are using read-only deployment keys.

便于在使用只读部署密钥的服务器上进行快速编辑。

回答by Yang

First bitbucket support ssh accesses.

第一个 bitbucket 支持 ssh 访问。

I think you may add your key under a repo. The key in the repo is a deploy key and it doesn't have write permission.

我认为您可以在回购下添加您的密钥。存储库中的密钥是部署密钥,它没有写入权限。

If you want push permission, you should add the key under your account.

如果你想要推送权限,你应该在你的帐户下添加密钥。

The link likes https://bitbucket.org/account/user/#{the-org-name}/ssh-keys/.

链接喜欢https://bitbucket.org/account/user/#{the-org-name}/ssh-keys/