Git:我应该如何将分支和分支的分支更改为master?

时间:2014-03-12 17:25:48

标签: git git-svn

我将master分括为feature。然后,我将feature分支为feature2。现在我想将所有更改到master。我怎么做?我以为我会这样做:

git rebase master feature #to make sure history is linear
git rebase feature feature2 #to make sure history is linear
git checkout feature
git merge feature2 --ff-only
git checkout master
git merge feature --ff-only

这可以解决这个问题吗?我希望我的历史是线性的,因为我使用git-svn并且我听到非线性历史会混淆它。

1 个答案:

答案 0 :(得分:1)

那会让你到达你想去的地方。您可以省略feature2的合并 - >功能并将feature2直接合并到master中,如果你想要一组稍微简单的命令。

git rebase feature feature2    # Ensure that all feature changes are
                               # included in feature2

git rebase master feature2     # Create a linear history
git checkout master
git merge feature2             # Merge feature2, which contains feature,
                               # into master