Create a Merge Request from the Command Line

If you use Git commands to manage source files from your computer, you can create merge requests from the command line when you're publishing changes to a project's repository. You can also add reviewers to merge requests made from the command line.

Use git push options to create a merge request that publishes changes from your local branch to a remote branch:

git push -o mr.target=<target-branch> origin <feature-branch>

where:
  • <target-branch> is the branch where your changes will be merged.
  • <feature-branch> is the branch to be reviewed. If the feature-branch you specify is already under review, the merge request won't be created.

For example, this command creates a merge request for the branch myfeature before merging to main:

git push -o mr.target=main origin myfeature

Note:

The Git push -o option is available only with Git version 2.10 or higher. With these versions, you can use the --push-options option or the shorter -o option.

If your merge request option includes text with spaces, enclose the text in double quotes (" "). If there are no spaces, the quotes are optional.

To add reviewers to the merge request, include the mr.add.reviewer option (or use the mr.add.defaultReviewers option to set default reviewers for the target branch). For example, this command identifies two reviewers (clara.coder and tina.testsuite) by their user names:

git push -o mr.target=main -o mr.add.reviewer=clara.coder,tina.testsuite origin myfeature

Both users will be added as reviewers to the merge request for the myfeature branch.

If you're adding reviewers from an Oracle Cloud Application environment that has multiple VB Studio instances in different IDCS identity stripes (or IDM identity domains), use the domain username format that includes the stripe or domain where that user has been defined. Since a unique user may have been defined for multiple domains or stripes, this format ensures that one identity can be distinguished from that user's other unique identities. This should ensure that the user you select is the correct one.

To add a reviewer from a multi-stripe environment to the example above, you need to pass the full domain username, which would be something like : "<idcs-idm_identifier_for_environment_user_is_associated_with>/username" ". This identifier indicates that the username belongs to a unique user in a specific instance in the multi-stripe environment.

The command for adding user tina.testsuite in a specific identity stripe as a reviewer is as follows:
git push -o mr.target=main -o mr.add.reviewer="idcs-e13d5ccf9...7684a6b283ce/tina.testsuite" origin myfeature

Tip:

If you frequently create merge requests, it may be helpful to add an alias for the create merge request option. This needs to be added to the .git/config file at the local level for each repository (refer to Git documentation for details). For example:
cat .git/config 
[alias]
   review = push -o mr.target=main

After doing that, you can use the review alias to create a merge request for the myfeature branch and add clara.coder as the reviewer, for example:

git review -o mr.add.reviewer=clara.coder origin myfeature

Note:

You cannot use the options to create a merge request and add reviewers with the git push --all command or for references other than the HEAD branch.
You can also add a group as reviewers. After you clone a repository and make some changes in a branch (for example, feature123), add and commit your changes. Create a group (for example, reviewers123) and add it as a member of the project that contains the repository you cloned. Then, from your clone, issue a command similar to this one:
git push -o mr.target=main -o mr.add.reviewer="reviewers123" origin feature123
Here are the additional options for a merge request, including adding a summary, description, and linking issues to the request:
Option Description
mr.reviewers | mr.reviewer | mr.add.reviewer Add reviewers to a merge request. Separate multiple reviewers with commas. For example:
-o mr.reviewers=clara.coder,tina.testsuite
mr.default-reviewers | mr.add.defaultReviewers Add the default reviewers to a merge request. For example:
-o mr.add.defaultReviewers
mr.summary Add a summary of the merge request. For example:
-o mr.summary="Summary of the MR"
mr.description Add a description of the merge request. For example:
-o mr.description="Description of the MR."
mr.issues | mr.issue Link issues to a merge request. Separate multiple issues with commas. For example:
-o mr.issues=VBS-33997,VBS-33998

Note:

If a merge request already exists, you don't need to specify the target branch when adding an issue or a reviewer (-o mr.target can be omitted).
After your changes have been successfully pushed and the merge request has been created, click the See merge request link included in the command output to view the merge request that was created for you in VB Studio, for example:

user123@rmt123 /tmp/code2cloud.example (myfeature) $ git push -o mr.target=main origin myfeature

Enumerating objects: ...

...

remote: [Push Options] See merge request: http://192.0.2.1:8888/test/?_h=projects/test_example/review/39

If you omit push options when pushing updates to a branch without a merge request, the command output includes the command format to create a merge request, along with a link to the New Merge Request UI wizard for the branch. The link opens the New Merge Request wizard with the Repository and Review Branch fields already populated. For example:

C:\Users\user123\git\tutorial-hr-project>git push origin hrbranch
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 22 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 287 bytes | 287.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1)
remote: [Merge Request] Do you want to create a merge request? Use git push -o mr.target=<target-branch> origin <feature-branch>
remote:  or click on https://url123.com/?_h=projects/dev-test_user123-test_40689/reviews&new=true&repo=tutorial-hr-project.git&branch=hrbranch
remote: Updating references: 100% (1/1)
To https://url123.com/s/dev-test_user123-test_40689/scm/tutorial-hr-project.git
   249fcd5..76f7aaa  hrbranch -> hrbranch

If you omit push options when pushing updates to a branch that already has a merge request, the command output includes a link to the updated Merge Request UI page for the branch. For example:

C:\Users\user123\git\tutorial-hr-project>git push origin hrbranch
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 22 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 323 bytes | 323.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1)
remote: [Merge Request] https://url123.com/s/dev-test_user123-test_40689/review/1 (updated)
remote: Updating references: 100% (1/1)
To https://url123.com/dev-test/s/dev-test_user123-test_40689/scm/tutorial-hr-project.git
   76f7aaa..7a7c0cd  hrbranch -> hrbranch