git 合并父分支到子分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31874670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:26:28  来源:igfitidea点击:

Merge parent branch into child branch

gitmergebranchatlassian-sourcetree

提问by VansFannel

I'm using bitbucket and sourcetree and I've done this:

我正在使用 bitbucket 和 sourcetree,我已经这样做了:

I have a develop branch. From this branch I have created a feature branch.

我有一个开发分支。从这个分支我创建了一个功能分支。

After creating I have fix some errors on develop branch and push it to this branch only.

创建后,我修复了开发分支上的一些错误并将其推送到此分支。

How can I have these fixes in the feature branch? I think I have to merge develop branch into feature branch but I'm not sure because I'm new in git and I don't want to do something wrong that makes me lose develop branch. but now I want to have these fixes on my feature branch.

如何在功能分支中进行这些修复?我想我必须将 develop 分支合并到 feature 分支中,但我不确定,因为我是 git 新手,我不想做错事让我失去 develop 分支。但现在我想在我的功能分支上进行这些修复。

What do I have to do?

我需要做什么?

回答by Aditya Kadakia

You want to bring changes from development branch to feature branch. So first switch to feature branch and merge development branch into it. In case you want the commits from develop branch too, use the non fast forward merge --no-ffapproach. Else do not use --no-ff.

您希望将更改从开发分支带到功能分支。所以首先切换到功能分支并将开发分支合并到其中。如果您也想要来自开发分支的提交,请使用非快进合并--no-ff方法。否则不要使用--no-ff.

git checkout feature
git merge --no-ff develop

As you are merging develop branch into feature branch, stay assured that develop branch will remain untouched. You may get merge conflicts in feature branch which can be easily solved following the steps on this link: http://softwarecave.org/2014/03/03/git-how-to-resolve-merge-conflicts/

当您将开发分支合并到功能分支时,请确保开发分支将保持不变。您可能会在功能分支中遇到合并冲突,可以按照以下链接中的步骤轻松解决:http: //softwarecave.org/2014/03/03/git-how-to-resolve-merge-conflicts/

回答by LcKjus

Yes you can merge or preferably rebase develop in your feature.

是的,您可以在您的功能中合并或最好重新开发。

git checkout feature
git rebase develop

If you get merge errors you can skip rebase by

如果您遇到合并错误,您可以通过以下方式跳过变基

git rebase --skip

or solve the conflicts and continue with (after adding your solution):

或解决冲突并继续(添加解决方案后):

git rebase --continue

Also see this question

也看到这个问题