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>
<target-branch>
is the branch where your changes will be merged.<feature-branch>
is the branch to be reviewed. If thefeature-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.
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.
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 thegit push --all
command or for references other than the HEAD branch.
git push -o mr.target=main -o mr.add.reviewer="reviewers123" origin feature123
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