Reputation: 3380
I need to create a GitLab Merge Request to the master branch containing one commit which I have made on my fork.
I have, however, already an open Merge Request to the master branch.
When I try to create a new one, the pending commits from the (open) MR are also included.
How can I specify in my MR to use only one specific commit? (and not the old ones) ?
Will this work? https://docs.gitlab.com/ee/user/project/merge_requests/cherry_pick_changes.html#cherry-picking-a-merge-request
Thanks!
Upvotes: 5
Views: 22303
Reputation: 1324278
With GitLab 13.11 (April 2021), you have an alternative workflow:
Cherry pick commits from fork to parent
With GitLab 13.11, if you are a project member, you can now cherry-pick commits from downstream forks back into your project.
We’ve added a new Pick into project section to the cherry-pick dialog, shown when you select
Options > Cherry-pick
on a commit’s details page.Your community of contributors can contribute to your project, and your team no longer needs to manually download a fork’s
.patch
file to pull in good changes from stale or unmaintained forks.Future enhancements include cherry-picking commits from fork to fork.
See Documentation and Issue.
Upvotes: 4
Reputation: 36
Follow below steps: 1.Delete Merge Request and branch from github. 2.Run command: git log and keep safely your commit ids which you want. 3. Delete your branch from local. 4. Create new branch again from same source. 5. And run below command for every commit id. From bottom to top.(use latest commit in the last) git cherry-pick 6. Push the branch.
Upvotes: 0
Reputation: 14459
A Merge Request from one branch to another will always contain all commits that the branch to merge
contains since it branched off from the branch to merge into
(in your case: master
). You can, however, create a new branch from your master
branch, cherry-pick the single commit, and create a merge request for that branch, containing only the one commit.
If you do not need the other commits any more, you can also consider an interactive rebase, to remove the unwanted commits from the branch.
The cherry-pick feature in GitLab for merge requests is only available after a merge request was merged. It allows yout to transfer the merged changes to another branch, for example when you need to deploy hotfixes to a release branch and after that cherry pick them to the master branch.
Upvotes: 7