Git:跨分支团队协作,无需推送权限

发布于 2024-11-19 12:50:16 字数 1383 浏览 0 评论 0 原文

我目前在一个 Scrum 团队工作,该团队与另一个 Scrum 团队使用共享的 git 存储库。为了方便起见,我们将我的 Scrum 团队称为“汽车人”,将另一个团队称为“霸天虎”。

霸天虎团队拥有对存储库的完全推拉访问权限,并负责该框架。

汽车人团队能够拉动,但不能推动。一般来说,如果团队成员独立工作,是没有问题的。然而,在某些情况下,拉动和推送到另一个团队成员分支会很有用。到目前为止,汽车人尚未获得霸天虎的推送访问权限(简单修复),因此需要解决方法。

用例示例:考虑 Optimus(继续变形金刚的比喻)是否已完成以下操作:

#!/bin/bash
optimus@workstation0:~/git/work_project/> git branch sdev /sprint/dev --track
optimus@workstation0:~/git/work_project/> git checkout sdev
optimus@workstation0:~/git/work_project/> touch important_file.py
optimus@workstation0:~/git/work_project/> git add important_file.py
optimus@workstation0:~/git/work_project/> git commit -m "Important file added."

现在,补足 通过编辑来帮助 Optimus important_file.py。他创建了自己的分支并直接从 Optimus 分支中拉取,并尝试推送:

#!/bin/bash
rodimus@workstation1:~/git/work_project/> git branch sdev /sprint/dev --track
rodimus@workstation1:~/git/work_project/> git pull ~optimus/git/work_project sdev
rodimus@workstation1:~/git/work_project/> echo "'''TODO: Add content''' > important_file.py
rodimus@workstation1:~/git/work_project/> git commit -m "Added TODO".
rodimus@workstation1:~/git/work_project/> git push ~optimus/git/work_project sdev

结果发生了错误。正确的程序是什么?不希望有第二个存储库,但如果需要的话可以这样做。

I am currently working for a Scrum Team that is using a shared git repository with another Scrum Team. For ease, we will call my scrum team Autobot and the other Decepticon.

Team Decepticon has full push and pull access to the repository, and are in charge of the framework.

Team Autobot is able to pull, but not to push. Generally there is no issue if members of the team work independently. However, cases arise where it would be useful to pull and push to another team members branch. As of yet, Autobot has not been granted push access by Decepticon (the easy fix) so a work around is required.

A use case example: Consider if Optimus (To continue the transformers metaphor) has done the following:

#!/bin/bash
optimus@workstation0:~/git/work_project/> git branch sdev /sprint/dev --track
optimus@workstation0:~/git/work_project/> git checkout sdev
optimus@workstation0:~/git/work_project/> touch important_file.py
optimus@workstation0:~/git/work_project/> git add important_file.py
optimus@workstation0:~/git/work_project/> git commit -m "Important file added."

Now, Rodimus is to help Optimus by editing important_file.py. He creates his own branch and pulls straight from Optimus's branch, and tries to push:

#!/bin/bash
rodimus@workstation1:~/git/work_project/> git branch sdev /sprint/dev --track
rodimus@workstation1:~/git/work_project/> git pull ~optimus/git/work_project sdev
rodimus@workstation1:~/git/work_project/> echo "'''TODO: Add content''' > important_file.py
rodimus@workstation1:~/git/work_project/> git commit -m "Added TODO".
rodimus@workstation1:~/git/work_project/> git push ~optimus/git/work_project sdev

And errors occur. What is the Proper procedure for this? It is undesirable to have a second repository, but do-able if required.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情定在深秋 2024-11-26 12:50:16

2014 年更新(3 年后)

正如 Adrien Be评论

Stash 实现了分支级别权限

请参阅“使用分支权限

https://confluence.atlassian.com/download/attachments/313460915/STASH20_branch_perm_adv.png?version=4&modificationDate=1376470584184&api=v2&effects=border-simple,blur-border


原始答案(7 月) 2011)

通常的解决方案是第二个存储库,其中:

  • Team Autobot可以推送到
  • 霸天虎团队可以定期获取并查看是否有任何内容可以合并

但这需要第二个存储库。

另一种解决方案是使用像 Gitolite 这样的授权框架,提供 推送对汽车人分支的访问
它只需要一个存储库,但需要一台服务器(ssh 或 apache)能够对推送到所述存储库的用户进行身份验证(因为 本地协议没有身份验证)。

因此,这两种解决方案都不是一个容易解决的问题。

Update 2014 (3 years later)

As mentioned by Adrien Be in the comments

Stash implemented branch level permissions

See "Using Branch Permission"

https://confluence.atlassian.com/download/attachments/313460915/STASH20_branch_perm_adv.png?version=4&modificationDate=1376470584184&api=v2&effects=border-simple,blur-border


Original answer (July 2011)

The usual solution is a second repo where:

  • Team Autobot can push to
  • Team Decepticon can regularely fetch and see if there is anything to merge

But that would require a second repo.

Another solution would be, with an authorization framework like Gitolite, to give push access to an Autobot branch.
It requires only one repo, but with a server (ssh or apache) able to authenticate the user pushing to said repo (since the local protocol don't have authentication).

So both solutions aren't an easy fix.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文