I'm using bitbucket and sourcetree and I've done this:
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.
What do I have to do?
Child branches are not affected by merges of their parent branches. Branches are basically just a concept for human users, git only sees commits.
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
The solution is to use git rebase --onto after rebasing the first branch. This will rebase all commits of feature2 that follow the old head of feature1 (i.e. F ) onto the new head of feature1 (i.e. F' ).
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-ff
approach. Else do not use --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/
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With