All Products
Search
Document Center

Alibaba Cloud DevOps:Push review mode

Last Updated:Jun 19, 2025

Push review mode simplifies the git push workflow by automatically creating and managing code reviews without additional tools. This improves code quality and collaboration efficiency.

Background

The AGit-Flow mode in Codeup supports creating code reviews via the command line using git pr. This mode requires developers to install the git-repo tool locally.

But most developers want to merge approved code to target branch without additional tools. To achieve this, Codeup introduces the push review mode, allowing developers to create code reviews by simply executing git push, without using external tools like git-repo.

Push review mode and its advantages

Push review mode is a new code collaboration method introduced by Codeup to bring users a fresh and efficient code review experience:

  • For developers, initiating code reviews no longer requires creating new branches or switching to a browser to create reviews after development is complete. Just execute git push to initiate a review.

  • For administrators, just set up a system that automatically creates a code review instead of directing updating the branch code when developers push code to the repository. This process ensures code quality through the review mechanism.

The following table compares the push review mode and the existing branch mode.

Branch development mode

Push review mode

Committing code

Commits code to the feature branch.

Commits code directly to the master branch.

Initiating a code review

Initiates a code review on the Codeup web page.

Executes git push.

Updating a code review

Updates the feature branch.

Continues to execute git push.

Permission required to contribute code

Developer or higher-level roles

Viewer or higher-level roles

Code quality

Controls the quality of code pushed only to protected branches.

Controls the quality of code pushed to all branches.

After you enable push review mode in the repository settings, the mode offers the following advantages:

  • To contribute code to the repository and initiate code reviews, you no longer need to create new branches. You can make changes and commit the changes directly to the main branch, avoiding the overhead of redundant branch management.

  • git push no longer directly pushes branch content but creates or updates code reviews.

  • If code needs to be modified, after committing the code, you can continue to execute git push, and the initiated review will be automatically updated.

  • Contributing code to the repository no longer requires developer permissions. With viewer permissions on the repository, you can contribute code, and the contributed code needs to be reviewed before it is officially merged into the codebase. Therefore, direct write permissions on the repository can be limited to a few administrators, while most developers only need read permissions, reducing the risk of accidental modifications to the codebase.

  • This mode allows you to specify push option to control specific push behaviors. For more information, see the Use push review mode for collaboration section.

How to enable push review mode

In Repository Settings > Push Rule Settings, you can see the switch for push review mode. Click this switch to enable or disable push review mode.

image

Important

After you enable push review mode, the behavior of git push will change. Make sure that you are aware of the following changes before enabling push review mode:

  • After enabling push review mode, executing git push no longer directly updates the remote code (even with developer permissions on the repository). Instead, code reviews are automatically created or updated.

  • Repository viewers can initiate reviews through git push, but rest assured that the code has not yet been merged into the branch. It needs to be manually merged after meeting the branch review and merge requirements.

  • Since git push does not directly update code but creates a review, it will not trigger push event webhooks.

  • Users can create, edit, or delete files through the review process on the Codeup web page.

Use push review mode for collaboration

In this section, several practical examples are used to explain how to use push review mode for development collaboration.

Automatic review creation

Suppose you receive a development task. You can use push review mode to simplify the process to two steps:

  1. Develop on the master branch.

  2. Execute git push.

Let's take a closer look.

  1. Develop on the master branch of the sample repository and commit 27e76f58.

    $ git log
    commit 27e76f582ca7207a695dd8762b66ef443adcc572 (HEAD -> master)
    Author: Codeup User <codeup.user@example.com>
    Date:   Tue Oct 11 10:16:18 2022 +0800
    
        feat: new feature
    
        Signed-off-by: Codeup User <codeup.user@example.com>
    
    commit 44094ec92eb122deab5a0367552bd081540c4353 (origin/master, origin/HEAD)
    Author: Codeup User <codeup.user@example.com>
    Date:   Tue Oct 11 10:09:39 2022 +0800
    
        Initial commit
  2. Then, push the changes to the remote repository by executing git push:

    $ git push
    Enumerating objects: 4, done.
    Counting objects: 100% (4/4), done.
    Compressing objects using 12 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 310 bytes | 310.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    remote: +-----------------------------------------------------------------------------------+
    remote: | The following tips are provided by Codeup:                                        |
    remote: +-----------------------------------------------------------------------------------+
    remote: | Merge request #31620 has been created, please visit:                              |
    remote: | https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31620       |
    remote: +-----------------------------------------------------------------------------------+
    To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
     * [new reference]         master -> refs/merge-requests/31620/head

After you enable push review mode, git push does not directly update the remote code but creates a code review with ID 31620. The source of this code review is the latest local commit, and the destination is the current branch. This can be confirmed through the code review details.

高的 (55)

Through this method, you no longer need to create feature branches or switch to a browser to create reviews, greatly simplifying the workflow. Additionally, git push must pass review before it can be merged, ensuring code quality.

Automatic review update

During the code review process, it is often necessary to repeatedly modify the code based on the reviewer's comments before the code can meet the code acceptance criteria. So, after the code is modified, how is the corresponding code review updated? The following section introduces how to use git push to automatically update reviews.

First, based on 27e76f58, modify some code according to review comments and commit e00db452.

$ git log
commit e00db4522f2d6ca5b42377ca76c7b3a7e12db8a5 (HEAD -> master)
Author: Codeup User <codeup.user@example.com>
Date:   Tue Oct 11 11:09:42 2022 +0800

    feat: fix comment

    Signed-off-by: Codeup User <codeup.user@example.com>

commit 27e76f582ca7207a695dd8762b66ef443adcc572
Author: Codeup User <codeup.user@example.com>
Date:   Tue Oct 11 10:16:18 2022 +0800

    feat: new feature

    Signed-off-by: Codeup User <codeup.user@example.com>

commit 44094ec92eb122deab5a0367552bd081540c4353 (origin/master, origin/HEAD)
Author: Codeup User <codeup.user@example.com>
Date:   Tue Oct 11 10:09:39 2022 +0800

    Initial commit

Then, after executing git push, the system automatically updates the code review status and displays relevant prompt information.

$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Compressing objects using 12 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 340 bytes | 340.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: +-----------------------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                                        |
remote: +-----------------------------------------------------------------------------------+
remote: | Merge request #31620 has been updated, please visit:                              |
remote: | https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31620       |
remote: +-----------------------------------------------------------------------------------+
To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
   27e76f582c..e00db4522f  master -> refs/merge-requests/31620/head

According to the prompt information, this push updates the code review with ID 31620. Upon checking the review details, you can see that the source version of the code review has been changed to e00db4522, and the number of commits has been changed to 2. If the code still needs to be modified, simply repeat the preceding process.

Create a new review

When you repeatedly execute the git push command, it will automatically update existing reviews. If you do not want to update a review but want to create a new one, add push option to the push command. Specifically, executing git push -o review=new will create a new code review.

After making some local code changes, execute git push -o review=new. Then, a code review with ID 31626 is successfully created.

$ git push -o review=new
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Compressing objects using 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 361 bytes | 361.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: +-----------------------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                                        |
remote: +-----------------------------------------------------------------------------------+
remote: | Merge request #31626 has been created, please visit:                              |
remote: | https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31626       |
remote: +-----------------------------------------------------------------------------------+
To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
 * [new reference]         master -> refs/merge-requests/31626/head

Note: If there is already a review that contains exactly the same changes as those in your current push, you cannot create a new review.

$ git push -o review=new
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: +-----------------------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                                        |
remote: +-----------------------------------------------------------------------------------+
remote: | Merge request create failed. There exists a same merge request in progress:       |
remote: | https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31620       |
remote: +-----------------------------------------------------------------------------------+
To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
 ! [remote rejected]       master -> master (create MR failed)
error: Failed to push some references to 'https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git'

Update a specific review

When there are multiple open code reviews, executing git push will fail because it cannot determine which review you want to update.

$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Compressing objects using 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 294 bytes | 294.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: +-------------------------------------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                                                      |
remote: +-------------------------------------------------------------------------------------------------+
remote: | You need to manually specify the merge request to update because there are already              |
remote: | multiple merge requests that you created earlier for the same target branch:                    |
remote: |                                                                                                 |
remote: | * [ID: 31626] https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31626       |
remote: | * [ID: 31620] https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31620       |
remote: |                                                                                                 |
remote: | Then, update specific merge request based on it's ID (MR-ID):                                   |
remote: |     git push -o review=<MR-ID>                                                                  |
remote: |                                                                                                 |
remote: | Or you can create a new one:                                                                    |
remote: |     git push -o review=new                                                                      |
remote: +-------------------------------------------------------------------------------------------------+
To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
 ! [remote rejected]       master -> master (unable to determine which mr to update)
error: Failed to push some references to 'https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git'

The prompt information shows that there are two reviews for the same target branch, with IDs 31626 and 31620. Therefore, the system cannot determine which review you want to update. There are two solutions to this problem:

  • Use -o review=new to create a new code review.

  • Use -o review=<MR-ID> to specify the review ID to update.

The first method has already been demonstrated in the Create a new review section. Let's see how to update a specific review.

Suppose we want to update the review with ID 31626. The command would be git push -o review=31626.

$ git push -o review=31626
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Compressing objects using 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 303 bytes | 303.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: +-----------------------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                                        |
remote: +-----------------------------------------------------------------------------------+
remote: | Merge request #31626 has been updated, please visit:                              |
remote: | https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31626       |
remote: +-----------------------------------------------------------------------------------+
To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
   0ba010f2ff..037578c634  master -> refs/merge-requests/31626/head

This way, we have updated the code review with ID 31626.

Resolve review update conflicts

When you want to update a code review, you may find that the review has already been updated by another user. In this case, the system prevents your update from going through to avoid overwriting the changes made by the user. Suppose we want to update review 31644. Execute the git push -o review=31644 command.

$ git push -o review=31644
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Compressing objects using 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 326 bytes | 326.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: +--------------------------------------------+
remote: | The following tips are provided by Codeup: |
remote: +--------------------------------------------+
remote: | MR is diverged with this push              |
remote: +--------------------------------------------+
To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
 ! [remote rejected]       master -> master (MR is diverged with this push)
error: Failed to push some references to 'https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git'

The prompt information indicates that this push would cause a conflict in the review, resulting in an update failure. Two options are available to address this issue:

  • Pull the update of another user, resolve any conflicts locally, and then update the review.

  • Forcibly update the review.

Take the first method as an example.

First, execute git fetch origin refs/merge-requests/<mr-id>/head. For this example, replace mr-id with 31644. As a result, the command to execute is git fetch origin refs/merge-requests/31644/head.

$ git fetch origin refs/merge-requests/31644/head
From https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo
 * branch                  refs/merge-requests/31644/head -> FETCH_HEAD

Then, rebase your local changes onto the references corresponding to the review. Execute git rebase FETCH_HEAD. The rebase operation may encounter conflicts. Resolve any conflicts according to your specific situation.

$ git rebase FETCH_HEAD
Successfully rebased and updated refs/heads/master.

Now, your local repository has the remote code. Execute a push again.

$ git push -o review=31644
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Compressing objects using 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 331 bytes | 331.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: +-----------------------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                                        |
remote: +-----------------------------------------------------------------------------------+
remote: | Merge request #31644 has been updated, please visit:                              |
remote: | https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31644       |
remote: +-----------------------------------------------------------------------------------+
To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
   a4a2cad45c..8da076fb44  master -> refs/merge-requests/31644/head

Forcibly update a review

If you do not want to merge the changes made by other users and want to force refresh the review with your local version. Here is how you can do it.

In this case, you need to know two values.

  • One is the ID of the code review, which is the last segment of numbers in the code review URL. For example, if the code review URL is https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31644, the ID of the review is 31644.

  • The other is the source version of the code review. This can be obtained from the details page of the code review. In this case, the corresponding source version is 8da076fb.

Then, you can execute git push -o review=<mr-id> -o old-oid=<old-oid>. For this example, the command would be git push -o review=31644 -o old-oid=8da076fb.

This way, you have refreshed the 31644 review with your local version. Note that during this process, the changes made by other users will be overwritten. To prevent the loss of these changes, execute this command only when you explicitly want to force refresh the version.

$ git push -o review=31644 -o old-oid=8da076fb
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: +-----------------------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                                        |
remote: +-----------------------------------------------------------------------------------+
remote: | Merge request #31644 has been updated, please visit:                              |
remote: | https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo/merge_request/31644       |
remote: +-----------------------------------------------------------------------------------+
To https://codeup.aliyun.com/61234c2d1bd96aa110f27b9c/demo.git
   8da076fb44..8da076fb44  master -> refs/merge-requests/31644/head

Skip review and directly update code

You may have committed only minor changes, such as correcting typos in code comments, and want to skip the code review. In this case, you can use the git push -o review=no command to skip creating a code review. The behavior of the command is consistent with executing git push when push review mode is not enabled. Note that you must have push permissions on the corresponding branch to use review=no to directly push code.

Some additional notes

You need to be either a reviewer or an author to update a review. Otherwise, the update will fail.

remote: +---------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                          |
remote: +---------------------------------------------------------------------+
remote: | Merge request #31644 update failed.                                 |
remote: | You need to be the author or reviewer to update this merge request. |
remote: +---------------------------------------------------------------------+