Reputation: 10828
Developers suppose to create a feature branch from master and then start coding but instead they have created a feature branch from develop branch and then merged into a develop branch. (not all the features from develop branch will be on master branch)
When I try to create a PR to merge his feature branch (not develop) to a release branch (release branch are created from a master branch) - it is showing commits on PR that he did not commit and the commits are showing from develop branch that does not exist on master branch. why did that happen?
Developer have only committed Task-6 Suspend Post
on to Task-6-Suspend-Post
branch.
Example:
https://github.com/superc0der/test/compare/RELEASE/1.5.0...Task-6-Suspend-Post?expand=1
Only Task-6 Suspend Post
should be merged on release branch. (https://github.com/superc0der/test/commit/62f68ec3d951bca5b848932df01ea8a29f0f562f)
Do I need to do cherry-pick or what is other solution to solve this? Having same problem with a few Features branches.
Upvotes: 2
Views: 78
Reputation: 83557
If it is a single commit, cherry pick is viable. However, rebase does a lot of the work for you to move the branch. With multiple commits, rebase also requires less work on your part.
With a develop branch with the current features and bug fixes, a common workflow is to create new feature branches from the develop branch rather than from master. Then the feature branch is merged into develop. Then a release branch can also be created from develop when you are ready and when the final release happens merge into master and tag the release.
Upvotes: 0
Reputation: 6157
A merging operation joins two (or more) branches together into a single commit (the merge commit). You have the below situation:
A - B (master)
\
C - D (develop)
\
E (Task-6-Suspend-Post)
Since Task-6-Suspend-Post
branch is created from develop
it contains commit C
and D
in its history. When performing merge of Task-6-Suspend-Post
into master
the following history will look like below:
A - B --------- G
\ /
C - D /
\ /
E
In other words the PR is a requets to create a merge commit for the latest on master
(B
) and the latest on Task-6-Suspend-Post
(E
). This will make commits C
and D
available through the history of master and thus included in the pull request.
Making a rebase of the Task-6-Suspend-Post
will solve your problem.
git rebase master Task-6-Suspend-Post
The above command will create a new commit E'
with the same content as E
but with the head of master (B
) as parent. The branch pointer Task-6-Suspend-Post
will be attached to the new E'
commit.
E' (Task-6-Suspend-Post)
/
A - B (master)
\
C - D (develop)
By force pushing the new Task-6-Suspend-Post
and making anew pull request only one commit should be part of the PR.
git push origin -f
Upvotes: 2