Revert changes

Tier: Free, Premium, Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated

You can revert individual commits or an entire merge request in GitLab.

When you revert a commit in Git, you create a new commit that reverses all actions taken in the original commit. The new commit:

  • Removes the lines added in the original commit.
  • Restores the lines removed in the original commit.
  • Restores the lines modified in the original commit to their previous state.

Your revert commit is still subject to your project’s access controls and processes.

Revert a merge request

After a merge request merges, you can revert all changes in the merge request.

Prerequisites:

  • You must have a role for the project that allows you to edit merge requests, and add code to the repository.
  • Your project must use the merge method Merge Commit, set in your project’s Settings > Merge requests.

    In GitLab 16.9 and later, you can revert fast-forwarded commits from the GitLab UI if either:

    • The commits are squashed, or
    • The merge request contains a single commit.

To revert merge request Example:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Code > Merge requests.
  3. From the secondary menu, select Merged, and select your merge request (here, Example).
  4. Scroll to the merge request reports area, and find the report showing the Merged by information.
  5. Select Revert.
  6. In Revert in branch, select the branch to revert your changes into.
  7. To revert immediately, without a merge request:
    1. Clear Start a new merge request.
    2. Select Revert, and the revert of Example is complete.
  8. To review the revert in a new merge request instead of reverting immediately, select Start a new merge request, then:
    1. Fill in the fields for your revert merge request, then select Create merge request.
    2. When the merge request merges, the revert of Example is complete.

After you revert the Example merge request, the option to Revert is no longer shown on it.

Revert a commit

You can revert any commit in a repository into either:

  • The current branch.
  • A new merge request.

Prerequisites:

  • Your role for the project must allow you to edit merge requests, and add code to the repository.
  • The commit must not have already been reverted, as the Revert option is not shown in this case.

To do this:

  1. On the left sidebar, select Search or go to and find your project.
  2. If you know the merge request that contains the commit:
    1. Select Code > Merge requests, then select your merge request.
    2. Select Commits, then select the title of the commit you want to revert. This displays the commit in the context of your merge request.
    3. Below the secondary menu, GitLab shows the message Viewing commit 00001111, where 00001111 is the hash of the commit. Select the commit hash to show the commit’s page.
  3. If you don’t know the merge request the commit originated from:
    1. Select Code > Commits.
    2. Select the title of the commit to display full information about the commit.
  4. In the upper-right corner, select Options, then select Revert.
  5. In Revert in branch, select the branch to revert your changes into.
  6. To revert immediately, without a merge request:
    1. Clear Start a new merge request.
    2. Select Revert.
  7. To review the revert in a new merge request instead of reverting immediately, select Start a new merge request, then:
    1. Fill in the fields for your revert merge request, then select Create merge request.
    2. When the merge request merges, the commit revert is complete.

Revert a merge commit to a different parent commit

When you revert a merge commit, the branch you merged to (often main) is always the first parent. To revert a merge commit to a different parent, you must revert the commit from the command line, see Revert and undo changes with Git.

Redact text from repository

History
  • Introduced in GitLab 17.1 with a flag named rewrite_history_ui. Disabled by default. GitLab team members can view more information in this confidential issue: https://gitlab.com/gitlab-org/gitlab/-/issues/450701
  • Enabled on GitLab.com in confidential issue https://gitlab.com/gitlab-org/gitlab/-/issues/462999 in GitLab 17.2.
  • Enabled on self-managed and GitLab Dedicated in confidential issue https://gitlab.com/gitlab-org/gitlab/-/issues/462999 in GitLab 17.3.

Permanently delete sensitive or confidential information that was accidentally committed, ensuring it’s no longer accessible in your repository’s history. Replaces a list of strings with ***REMOVED***.

caution
This action is irreversible. After rewriting history and running housekeeping, the changes are permanent. Be aware of the following impacts when redacting text from your repository:
  • Open merge requests might fail to merge and require manual rebasing.
  • Existing local clones are incompatible with the updated repository and must be re-cloned.
  • Pipelines referencing old commit SHAs might break and require reconfiguration.
  • Historical tags and branches based on the old commit history might not function correctly.
  • Commit signatures are dropped during the rewrite process.

Alternatively, to completely delete specific files from a repository, see Remove blobs.

Prerequisites:

  • You must have the Owner role for the project.

To redact text from your repository:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Settings > Repository.
  3. Expand Repository maintenance.
  4. Select Redact text.
  5. On the drawer, enter the text to redact. You can use regex and glob patterns.
  6. Select Redact matching strings.
  7. On the confirmation dialog, enter your project path.
  8. Select Yes, redact matching strings.
  9. On the left sidebar, select Settings > General.
  10. Expand Advanced.
  11. Select Run housekeeping.