简体   繁体   English

Git 功能分支工作流程

[英]Git feature branches workflow

I am trying to contribute to a project and I'd like to use git-flow workflow(?) on what I work.我正在尝试为一个项目做出贡献,我想在我的工作上使用 git-flow 工作流(?)。 Say, I have checkout'd the develop branch of the remote repository (github) and that I've setup 2 feature branches (T for Translation, U for Update):比如说,我已经检查了远程存储库(github)的develop分支,并且我已经设置了 2 个功能分支(T 代表翻译,U 代表更新):

---o---o---o (D)
           |---Ta---Tb (T)
           \---Ua---Ub---Uc (U)

Now, for each of the branches, a pull request is made to the upstream repository maintainer and he accepts them all and merges them to the upstream/develop branch.现在,对于每个分支,都会向upstream存储库维护者发出拉取请求,他接受它们并将它们合并到upstream/develop分支。

What is the correct procedure so that I end up with:什么是正确的程序,所以我最终得到:

---o---o---Ta---Tb---Ua---Ub---Uc (D)
                               |- (T)
                               \- (U)

Something tells me that git rebase is what I need.有些东西告诉我git rebase是我需要的。 (Please note I am on Windows). (请注意我在 Windows 上)。

You are right.你说的对。 You (or the repository maintainer) needs to rebase your changes onto your develop branch:您(或存储库维护者)需要将您的更改重新定位到您的开发分支:

git checkout develop
git rebase T
git rebase U

During the rebase, you might need to resolve conflicts if they occur.在 rebase 期间,如果发生冲突,您可能需要解决它们。

Your last branch diagram shows T and U have Uc as their parent.您的最后一个分支图显示 T 和 U 将 Uc 作为其父级。 The rebase won't change the branches parent.变基不会更改分支父级。 You can do this by deleting your branches and recreating them after the rebasing above.你可以通过删除你的分支并在上面的变基之后重新创建它们来做到这一点。

git branch -D T
git branch -D U

You'll need to use the capital -D switch to force the branch deletion because the T and U branch was never merged into the develop branch, so git doesn't know that the branch changes are reflected in the develop branch.您需要使用大写的 -D 开关来强制删除分支,因为 T 和 U 分支从未合并到开发分支中,因此 git 不知道分支更改反映在develop分支中。

After that, you can recreate them:之后,您可以重新创建它们:

git checkout -b T

git checkout develop
git checkout -b U

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM