如何与多个开发人员共享git功能(或主题)分支 [英] How to share a git feature (or topic) branch with multiple developers

查看:237
本文介绍了如何与多个开发人员共享git功能(或主题)分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循这里描述的工作流程,因为我发现许多指向这个页面的引用都是一个很好的工作流程。正如文章中提到的,功能分支是由开发人员共享的,但不要去中央存储库。假设开发者A用 git checkout -b newfeature develop 启动一个新的功能分支。现在让我们说开发者B也需要处理这个功能。这是我的问题。



我做了什么:


  1. 开发者B将开发人员A的计算机作为远程开发人员添加到开发人员B中运行 git branch remoteA / newfeature

  2. 开发者B在这个分支上工作,提交他的工作,并将这些改变推回到remoteA。

现在,第3步不起作用。我收到一条消息:


remote:error:默认情况下,更新非裸露的
存储库中的当前分支被拒绝,因为它会使索引和工作树
与你推送的内容不一致,并且需要'git reset --hard'
来匹配工作树和HEAD。


remote:错误:您可以在远程存储库中将'receive.denyCurrentBranch'配置
变量设置为'ignore'或'warn',以允许
推进其目前的分支;然而,除非您安排更新其工作树以匹配您以其他方式推送
的内容,否则不建议使用


remote:error:要压制此消息并仍保留默认的
行为,请将receive.denyCurrentBranch的配置变量设置为
'refuse'。

我已经设置了 sharedRepository = true ,但没有帮助。



我有两个问题:


  1. 什么是共享功能分支的正确方法在开发人员之间?

  2. 如何将开发人员B的存储库中的更改推回给开发人员A的原始人员?


解决方案

您可以推送到非裸回购。你不能做的是推到一个非裸露的回购,有你正在推出检查分支。这是有道理的。更改其他人可能正在处理的文件是不正确的。



通常,您需要推送到主或其他普通共享分支。为了避免这种冲突,远程非裸回购的所有者应该在本地分支或至少某个其他分支上工作。然后您可以推送到共享分支。



使用您的示例:


  1. 开发人员B将开发人员A的机器添加为远程

  2. 开发人员B运行 git分支remoteA / newfeature


    1. 开发者A在本地分支上工作。 git checkout -b work-newfeature


  3. 开发者B分支,完成他的工作,并将更改推回到remoteA。


    1. 开发人员A获得新工作: git rebase newfeature



I'm following the the workflow described here, as I found many references pointing to this page as a good workflow. As mentioned in the article, "feature" branches are shared between developers, but do not go to the central repository.

Let's say a developer "A" starts a new feature branch with git checkout -b newfeature develop. Now let's say that developer "B" needs also to work on this feature. This is my problem.

What I did:

  1. developer "B" adds developer A's machine as a remote
  2. developer "B" runs git branch remoteA/newfeature
  3. developer "B" works on this branch, commit his work and pushes the changes back to remoteA.

Step 3 is not working, right now. I get a message:

remote: error: By default, updating the current branch in a non-bare repository is denied, because it will make the index and work tree inconsistent with what you pushed, and will require 'git reset --hard' to match the work tree to HEAD.

remote: error: You can set 'receive.denyCurrentBranch' configuration variable to 'ignore' or 'warn' in the remote repository to allow pushing into its current branch; however, this is not recommended unless you arranged to update its work tree to match what you pushed in some other way.

remote: error: To squelch this message and still keep the default behaviour, set receive.denyCurrentBranch' configuration variable to 'refuse'.

I have already set sharedRepository = true, but it did not help.

I have 2 questions:

  1. what's the correct way to share feature branches between developers?
  2. how can I push back the changes in developer B's repository to developer A's original one?

解决方案

You can push to a non-bare repo. What you cannot do is push to a non-bare repo that has the branch that you are pushing to checked out. The reason for this should make sense. Changing the files that someone else is possibly working on would be incorrect.

Typically you will want to push to master or some other common shared branch. In order to avoid this conflict, the owner of the remote non-bare repo should work on a local branch or at least some other branch. Then you can push to the shared branch.

To use your example:

  1. developer "B" adds developer A's machine as a remote
  2. developer "B" runs git branch remoteA/newfeature

    1. developer "A" does work on a local branch. git checkout -b work-newfeature

  3. developer "B" works on this branch, commit his work and pushes the changes back to remoteA.

    1. Developer "A" rebases to get the new work: git rebase newfeature

这篇关于如何与多个开发人员共享git功能(或主题)分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆