Reputation: 3752
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?
Upvotes: 3
Views: 3281
Reputation: 441
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.
Upvotes: 2
Reputation: 3752
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
Upvotes: 1
Reputation: 1666
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
Upvotes: 3