How to share a git feature (or topic) branch with multiple developers

后端 未结 2 979
闹比i
闹比i 2020-12-31 22:09

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 sh

2条回答
  •  臣服心动
    2020-12-31 22:39

    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

提交回复
热议问题