2

I have a branch called dev which is up-to-date with the origin/dev. I want to merge into the (protected) master with the following command, but it doesn't push either create the merge request.

$ git push -o merge_request.create -o merge_request.target=master
Everything up-to-date

How to create a merge request from an already pushed commit from CLI?

betontalpfa
  • 3,454
  • 1
  • 33
  • 65

3 Answers3

2

If your dev branch is up to date with the dev branch on origin, your git push command won't do anyting, because Everything up-to-date.

To create the merge request from CLI, create a new branch (from dev) to make the push happen:

git checkout -b dev2
git push -o merge_request.create -o merge_request.target=master
Aleksey Tsalolikhin
  • 1,518
  • 7
  • 14
1

I was trying to automate merge request creation, but wanted to do the push 1st and later on to create the actual merge request. I have used this trick to do it, after the original push went to the remote:

git commit --amend --no-edit
git push --force-with-lease  origin [branch_name] -o merge_request.create -o merge_request.target=master

The amend will keep the original commit unchanged, and allow you to push the same branch while creating the merge request.

Nightrain
  • 391
  • 3
  • 6
0

This solution is based on this, but mine is more general. The solution below creates a custom-named branch to push it, and it requests the delete of the newly created branch on merge.

# Create new unique merge-request branch ex: 1234abc-to-master
git checkout -b `git rev-parse --short HEAD`"-to-master"

# Create merge request with upstream this new branch
git push -u origin `git rev-parse --abbrev-ref HEAD` -o merge_request.create -o merge_request.target=master -o merge_request.remove_source_branch
betontalpfa
  • 3,454
  • 1
  • 33
  • 65