gitlab-org--gitlab-foss/doc/user/project/merge_requests/revert_changes.md

2.4 KiB

stage group info
Create Code Review To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments

Revert changes (FREE)

You can use Git's powerful feature to revert any commit by clicking the Revert button in merge requests and commit details.

Revert a merge request

NOTE: The Revert button is shown only for projects that use the merge method "Merge Commit", which can be set under the project's Settings > General > Merge request. Fast-forward commits can not be reverted by using the merge request view.

After the merge request has been merged, use the Revert button to revert the changes introduced by that merge request.

Revert merge request

After you click that button, a modal appears where you can choose to revert the changes directly into the selected branch or you can opt to create a new merge request with the revert changes.

After the merge request has been reverted, the Revert button is no longer available.

Revert a commit

You can revert a commit from the commit details page:

Revert commit

Similar to reverting a merge request, you can opt to revert the changes directly into the target branch or create a new merge request to revert the changes.

After a commit is reverted, the Revert button is no longer available.

When reverting merge commits, the mainline is always the first parent. If you want to use a different mainline, you need to do that from the command line.

Here's an example to revert a merge commit using the second parent as the mainline:

git revert -m 2 7a39eb0