Merge request with just one commit

Viewed 11782
3 Answers

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.

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.

https://about.gitlab.com/images/13_11/cherry_pick_commits_from_fork_to_parent.png -- Cherry pick commits from fork to parent

See Documentation and Issue.

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.

Related